P
Pmb
How are character strings input from the user. For example: Suppose I have
the code
____________________________________
#include <iostream.h>
int main()
{
char nameString[10];
cout << "Enter your name: ";
cin >> nameString;
cout << "\nThe name you entered was " << nameString<< endl;
return 0;
}
____________________________________
If I run this program and type in "Joe Shmoe" the output will be
------------------------------
Enter your name: Joe Shmoe
The name you entered was Joe
------------------------------
I assume this is because the stream was read up to the blank space between
"Joe" and "Shmoe". How do I get the whole character string read into
nameString?
Pmb
the code
____________________________________
#include <iostream.h>
int main()
{
char nameString[10];
cout << "Enter your name: ";
cin >> nameString;
cout << "\nThe name you entered was " << nameString<< endl;
return 0;
}
____________________________________
If I run this program and type in "Joe Shmoe" the output will be
------------------------------
Enter your name: Joe Shmoe
The name you entered was Joe
------------------------------
I assume this is because the stream was read up to the blank space between
"Joe" and "Shmoe". How do I get the whole character string read into
nameString?
Pmb