How to print some portion of a string?
string line;
line ("i am a good boy");
if I want to print just good boy, how do I do it?
This will do it.
1 2
|
string line("i am a good boy");
cout << (line.c_str())+7;
| |
Thanks
You can also use substr.
1 2
|
string line("i am a good boy");
cout << line.substr(7);
| |
Topic archived. No new replies allowed.