c++ - Getting input from user using cin -
I am using the Turbo C ++ 3.0 compiler
When using the following code < / P>
four * names; Cin & gt; & Gt; Name; Cout & lt; & Lt; Name;
When I input with space ... only the only saving character that was typed before the space .. like I had given the input "QWERT YUIOP" ... in the name "QWERT" Will happen;
Why any explaination ??
You need to allocate space for the four arrays in which you want to read the name Four * names;
will not work because it only declares a four indicator, not the four array
In addition to cin & lt; & Lt;
Only allows us to enter a word in the string (four names [30]).
However, there is a canon function that reads text containing text. Receive
cin.get (name, MAX)
All characters, including spaces, will be read or line characters after reading the maximum characters ( '\ N') and will put them in the name variable.
Comments
Post a Comment