>>> The standard input device is usually the keyboard.
>>> Cout is used in conjunction with the >>. The operator >> is known as extraction or get-from operator. The operator must be followed by the variable that will store the data that is going to be extracted from the stream.
>>> Cin is an object, predefined in C++ to correspond to the standard input stream. This stream represents data coming from the keyboard.
>>> The >> takes the value from the stream object on its left $ places in the variable on its right.
>>> For example :
int age;
cind >> age;
>>> The first statement declares a variable of type int called age and the second one waits for an input from cin ( the keyboard) in order to store it in this integer variable.
>>> Cin is an object, predefined in C++ to correspond to the standard input stream. This stream represents data coming from the keyboard.
>>> The >> takes the value from the stream object on its left $ places in the variable on its right.
>>> For example:
int age;
cin >> age;
>>> The first statement declares a variable of type int called age, and the second one waits for an inputs from cin (the keyboard) in order to store it in this integer variable.
>>> Cin can only process the input from the keyboard once the RETURN key has been pressed. Therefore, even if you request a single character the extraction from cin will not process the input until the used presses RETURN after the character has been introduced.
>>> You must always consider the type of the variable that you are using as a container with cin extractions. If you request an integer you will get an integer, if you request a character you will get a character and if you request a string of characters you will get a string of characters.
>>> You can also use cin to request more than one datum input from the user:
cin >> a >> b;
is equivalent to :
cin >> a;
cin >> b;
>>> In both cases the user must give two data, one for variable a and another one for variable b that may be separated by any valid blank separator: a space, a tab character or a newline.
No comments:
Post a Comment