W
WP
Hi!
Say I have string of the following form:
"integer stringpart". First an integer, then a space and then the
stringpart which may or may not contain additional spaces. I wanted to
separate the integer and the stringpart, so I tried:
istringstream iss(str);
int num;
iss >> num;
Ok, now num contains the int-part. But how do I get the rest into a
string variable? iss.str() returns the entire string and iss >>
astrinvar; only gets me a subpart if the stringpart contains spaces
Is a loop my only option here or have I missed something?
- WP
Say I have string of the following form:
"integer stringpart". First an integer, then a space and then the
stringpart which may or may not contain additional spaces. I wanted to
separate the integer and the stringpart, so I tried:
istringstream iss(str);
int num;
iss >> num;
Ok, now num contains the int-part. But how do I get the rest into a
string variable? iss.str() returns the entire string and iss >>
astrinvar; only gets me a subpart if the stringpart contains spaces
Is a loop my only option here or have I missed something?
- WP