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
When I was learning C ++, these input functions were a bit confusing. Here I will make a summary. I hope it will be helpful for later users to review them, if there are any errors, please kindly advise (all in this articleProgramAll run through VC 6.
Usage of functions such as Cin, Cin. Get (), Cin. Getline (), Getline (), and gets ()
When I was learning C ++, these input functions were a bit confusing. Here I will make a summary. I hope it will be helpful for later users to review them, if
1,CIN
Usage 1: the most basic and common usage. Enter a number:
# Include
Using namespace STD;
Main ()
{
Int A, B;
Cin> A> B;
Cout
}
Input: 2 [Press enter] 3 [Press enter]
Output: 5
Usage 2: accept a string. When "space", "tab", and "Press ENTER"
When I was learning C ++, these input functions were a bit confusing. Here I will make a summary. I hope it will be helpful for later users to review them, if there are any errors, please give me more advice (all the programs in this article are run
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
A few C ++ input functions are always unclear. Let's sum up!
1. Cin
1. Cin. Get ()
2. Cin. Getline ()
3. Getline ()
4. Gets ()
5. getchar ()
1. Cin>
Usage 1: the most basic and common usage. Enter a number:
# Include
Using
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.