Inputting material into the string will stop at whitespace characters such as space if you use the << operator to assign the information, but the string can have whitespace char if you initialize the string or if you use something like getline(). Once the string variable has a information that has whitespace in it the whitespace should be counted by either strlen() for null terminated strings or length() for STL strings. This should help illustrate the point.
char str[20] = "hello world";
cout << strlen(str) << endl;
std::string str1 = "hello world";
cout << str1.length() << endl;
Reputation Points: 718
Solved Threads: 373
Nearly a Posting Maven
Offline 2,253 posts
since Jul 2005