By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,233 Members | 1,806 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,233 IT Pros & Developers. It's quick & easy.

Getting a chararacter array to accept spaces

P: n/a
Is there a way to get a character array to accept spaces? The use of my
program enters the input like this: (6 + 5). Is there a way to get the
program to insert the space (" ") into the array?
Dec 11 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Nevermind, I was trying to do this via cin >>, but I have no problems with
cin.get().

"deanfamily" <de********@verizon.net> wrote in message
news:kI2nf.9203$Ea6.2086@trnddc08...
Is there a way to get a character array to accept spaces? The use of my
program enters the input like this: (6 + 5). Is there a way to get the
program to insert the space (" ") into the array?

Dec 11 '05 #2

P: n/a
deanfamily wrote:
Is there a way to get a character array to accept spaces? The use of my
program enters the input like this: (6 + 5). Is there a way to get the
program to insert the space (" ") into the array?


a) Don't use a character array. Use std::string instead. It will make your
life easier.

b) Sure you can have spaces in strings (and character arrays). Show us some
code so that we can help you.
Best

Kai-Uwe Bux
Dec 12 '05 #3

P: n/a
On Sun, 11 Dec 2005 23:46:43 GMT in comp.lang.c++, "deanfamily"
<de********@verizon.net> wrote,
Nevermind, I was trying to do this via cin >>, but I have no problems with
cin.get().


See also getline()

Dec 12 '05 #4

P: n/a
Use:

cin.unsetf(ios_base::skipws);

And

cin>>your_string;

will get the string with spaces and such.

Dec 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.