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