I use this:
but when the user enters "Jane Doe" the name string only contains "Jane". How can I fix this?Code:string name; cin >> name;
try using cin.getline(name)
or use
#include <string>
and then, declare your string like
string str1;
cout << "Enter the name blah blah:\n";
getline(cin, str1);
should work fine
Last edited by icepack; 11-12-2006 at 04:47 PM. Reason: find vs. fine
The space is causing cin >> to terminate. Using the getline like suggested will read until a linebreak.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks