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 the name of the character [30];

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

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

c++ - QtQuick: QQmlApplicationEngine failed to load component qrc:/main.qml:23 Invalid attached object assignment -