Mainly organize the teacher's ppt notes in class
1.c ++ input and output
Use cin, cout, and stream operators, starting with
#include<iostream>
(1) cin statement: cin >> variable name 1 >> variable name 2 >> ... >> variable name n;
(2) cout statement: cout << expression 1 << expression 2 << ... << expression n;
Note: Unlike scanf, the system uses white space as a separator between data (including character variables), cin automatically skips the entered white characters ( space, carriage return, tab
), and enter the white characters from the keyboard to assign to the character variable, You can use getchar ()
;
2. Use control characters in standard input and output streams
Special requirements to set the output data
at the beginning of the program must have
#include<iomanip>
Where setw only works on the first data after it
3. String
At the beginning of the program
#include<string>