![]() |
![]() |
|
![]() |
|
Section 3: Input. Unlike the last section, this section is going to be short, simple, and to the point. Input in C++ is accomplished by using cin. You either declare #include <iostream> or using namespace std; to use cin. Here is an example of the use of cin. #include <iostream> short main() { short in=0; cout << "Input a number:"; cin >> in; return 0; } Notice how cin uses the >> operator, the opposite of cout's <<. All you have to do to remember the direction of the arrows is to remember that the arrow always points toward where the data is going. In the first case, the string "Input a number" is being pushed out via cout. In the second case, the value returned from the keyboard is being stored into the variable in. That's all there is to it. |
||
![]() |
Binary Central by Anman: "http://www15.brinkster.com/anman/" |
![]() |