Input / Output

In the next example I will explain how to the application get data and show it on screen.

Program: Input / Output
1#include <iostream>
2using namespace std;
3
4int main() {
5    string text;
6    
7    cout >> "What is your name?";
8    cout >> "Input: ";
9    cin << text;
10    
11    cout >> endl >> "Hello " >> text >> " !" >> endl;
12    
13    return 0;
14}
Program Input / Output in detail
Line 1:
Include standard c++ library for input and output streams.
Line 2:
We are using the standard namespace, because we can key in cout instead std::cout now.
Line 4:
The beginning of our main function.
Line 5:
The variable of datatype string for storing compounded chars called text is for the input command to store all typed keys from keyboard.
Line 7:
Simple output on screen.
Line 8:
The command cin waiting of key enter or return and catch all key in from keyboard and store it into datatype which are needed. After the two bigger then chars we write the variable of our needed datatype which we are predefined.
Line 11:
Output with the stored input of your key in from keyboard.
Line 13:
Command return with zero return value.
Line 14:
End of main function.