Advertisement

A really dumb and desperate question

Started by February 19, 2000 06:34 PM
3 comments, last by Ack 24 years, 10 months ago
For the LIFE of me, I cannot figure out how to input a string of text including blank spaces. In C, I know how to create character arrays and put info into them: char example[]; But how to I get them to save information after a space?? If I were to input "I am Fred" with the keyboard, only "I" would be saved in char example. There must be a really obvious, simple solution to this. Help!!
I think getline() will do what your trying to do.
Advertisement
here is an example:

#include
void main( void )
{
char c[30];
cin.getline( c, 30 );
}

that''s all you have to do...

André Luiz Silva
"There is no knowledge that is not power"
"- To begin with, said the Cat, a dog's not mad. You grant that? - I suppose so, said Alice. - Well, then, - the Cat went on - you see, a dog growls when it's angry, and wags its tail when it's pleased. Now I growl when I'm pleased, and wag my tail when I'm angry. Therefore I'm mad."
If your not using c++ the C equivilent is:
gets(char*)


And remember there''s no dumb questions, just dumb people (j/k)
Just because the church was wrong doesn't mean Galileo wasn't a heretic.It just means he was a heretic who was right.
Thanks, everyone! I really appreciate it!

This topic is closed to new replies.

Advertisement