Many beginners think that the CIN function is a very simple function! The CIN function has a lot of knowledge to know (for example, what is the return value of CIN, And what member functions are provided by CIN, such as cin. clear (), Cin. ignore (),
Scanf, gets, getchar, cin, cin. get, cin. getline, getline summary, cin. getcin. getline
I. scanf
Scanf can be used to read numbers, characters, and strings;
Conclusion:(1) When scanf reads a single character (% c) from the buffer, if the first
Scanf (), getchar (), and so on are all standard input functions. Most people think these functions are very simple and there is nothing special about them. However, sometimes it is because the use of these functions does not solve the problem, but
Code compilation Run Environment QT creator
1.cin and cout introduction
CIN is a standard input stream object in the C + + programming language, that is, an object of the IStream class. CIN is mainly used to read data from standard input, where the
Let's look at the following code:#include #include #include intMain () {intnum =0;STD:: vectorint>Ivec Do{STD::cout"Please input some numbers:"STD:: Endl; while(STD::Cin>> num)//always detects input stream status know how to encounter file
Array:
Float loans [20];
The loans type is not "array" but "float array ". This emphasizes that the loans array is created using the float type.
String:
Char dog [5] = {'A', 'B', 'C', 'D', 'E'}; // not a string (not a string)
Char dog [5] = {'A', '
Differentiation of cin, cin. get (), cin. getline (), cin. getcin. getline
1 cin is mainly used to input numbers
# Include Using namespace std;Main (){Int a, B;Cin> a> B;Cout
Input: 1 Press enter 2 press ENTEROutput: 3
2 when cin receives a
1. CIN:how the input operation works , the input of the program is built with a buffer, which is the input buffer. The first input process is this, when the input data is stored in the input buffer at the end of the keyboard input, and the CIN
The end of CIN
If you use CIN>... If you have input before using cin. Getline, you need to process it. There are many processing methods. You can go to CIN>... Add the statements cin. Get ();.
Use
Use C + + Flow member function put output single characterThe cout and insert operator "
Cout.put (' a ');
The result of calling this function is to display a character a on the screen. The parameter of the PUT function can be the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.