String input

Ok I have been having a problem... When I ask for a string and use spaces it stops at the first space. I dont want to use a char array. And heres my code:

1
2
3
4
5
6
void setaddress(int i){
     string address;
     cout<<"Address: ";
     cin>>address;
     user[i].address=address;
}


I dont have access to my code right now so this is what i think it is.
With this if you put in "123 cool street" it only does 123. Please help if you can thanks in advance!
Ok thanks. I knew about that... i just didnt know you and to
#include <sstream>

Thanks!
closed account (S6k9GNh0)
You don't need to #include <sstream> . It's part of the IOStream
Last edited on
No, it's not.
Isn't the getline needed part of the <string> header? Why would you want the <sstream> header?
http://cplusplus.com/reference/string/getline/

The other getline which is a member of the input stream would be included with the <iostream> header. Either way, I don't see why <sstream> is needed in this example program.
http://cplusplus.com/reference/iostream/istream/getline/
Last edited on
Topic archived. No new replies allowed.