Help new in c++

Guys, I have the following problem: i ask the user (through the console) to enter a string. The length is unknown, and it may contain blank spaces.

The problem is the following:

1
2
string p="";
cin>>p;


only gives me words until the first space.
Even if i used char*, I still have the same problem.
Any ideas?
Oh, using cin.get(...) doesn't allow me to use the string object, and that's a real problem, because then i go back to the original thing... i want the user to be able to input as much chars as he wants
Last edited on
closed account (z05DSL3A)
Have a read here:
http://www.cplusplus.com/reference/iostream/istream/getline.html
I think you should look here instead:
http://www.cplusplus.com/reference/string/getline.html
closed account (z05DSL3A)
My bad, I thought I had followed the link to string string page from the page I referenced when I cut and pasted the address. It's Monday morning...what can I say.


Topic archived. No new replies allowed.