Multiple words in a string variable
Hello,
I am pretty new to C++. I have a problem when using the console to enter multiple words into a string variable i.e. add='123 cplusplus street'.
when I try to get a user to enter their address using cin it only captures the users 1st word entered i.e '123' rather then 123 cplusplus street.
the code i'm using is:
HTML Code:
string test;
cout << "Enter address: ";
cin >> test;
cin:afrog:
Thanks in advance
Re: Multiple words in a string variable
You want to use getline.
Code:
getline(cin, variable);
cout << variable;
Re: Multiple words in a string variable