string question 2

[code] string temp
cin>> temp;
cout << temp.length() <<endl;

for(int i=0 ; i < temp.length() ; i++){

cout << temp[i] <<endl;
}
/code]

if temp is "my name is something"
loop go through 4 times with 2,4,2,9


I want loop through once with full string length.

any idea?
Use functiom std::getline instead of operator >>.
Topic archived. No new replies allowed.