Question:
c++ simple way to enter spaces in a string?
tellitlikeitiz
2009-06-29 14:00:31 UTC
here's a sample of my code

cout<<"Phone Number: ";
cin>>entry[i].phoneNumber;
cout<<"City: ";
cin>>entry[i].city;

how do I get it to store spaces for the address and city??
Three answers:
tbshmkr
2009-06-29 15:40:30 UTC
Show your code.

=

Show your structure & members.
Paul
2009-06-29 14:21:26 UTC
If you want to get everything up to end of line including spaces then use, e.g.



getline(cin, entry[i].city);
harsha deep
2009-06-29 14:14:08 UTC
I am not sure what u mean by address and city ..

Where r u inputting address in ur code ..

nyway ,.. the simplest way to insert space into ur string is



insert( iterator i,char ch );



inserts ch before the character denoted by i,..

so find the character and insert a space


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...