The following code:
int main() {
stringstream ss;
string str;
str = "999:97 42:22 44:102300";
ss << str;
char ch;
int temp, temp1;
while (1) {
if (ss.fail()) {
break;
}
ss >> temp >> ch >> temp1;
cout << temp << ":" << temp1 << endl;
}
return 0;
}
This gives the following output:
999:97
42:22
44:102300
44:102300
Here's a link as well: http://ideone.com/cC75Sk
I just wanted to know, why does the code doesn't end after the break
statement ?