1. I/O Stream
I/O functions are not part of the C ++ language; they come from the C ++ standard library iostream;
1) iostream Library:
2) stream
In C ++, I/O processing is a stream. A stream is a finite ordered byte, also known as a buffer pool.
There are two main types of stream: input stream and output stream.
3) Input and Output in C ++
IOS is the most common input and output base class; istream and ostream process the original class of input and output;
4) Standard stream in C ++
Mainly include: Cin, cout, cerr and clog
CIN is mainly for keyboard input, and the last three are mainly for display output.
Cerr is a non-buffered output that can process data types. Clog is a buffer type and Outputs Data in blocks.
2. input stream
Iostream is a very complex library. The most common section is discussed here.
All I/O functions are in the STD namespace;
1) extract Operators
> It is the input extraction operator. Generally, it processes built-in data types. You can reload it to process custom data types.
2) extraction and blank symbols
You can enter a single character through>, but the blank space is ignored. You can use cin. Get (CH) to write down the blank space;
You can also use cin. Get (BUF, length) to obtain the input of the specified length;
You can also use cin. Getline (BUF, length) to obtain the input of the specified length;
Input that is applied to string: Getline (CIN, STR ).
Some useful istream functions:
Ignore (), discard the first character in the stream; ignore (INT count), discard the first count character in the stream;
Peek (): reads a character from the stream, but does not remove it from the stream; upget () returns the character retrieved last time; putback (char ch) puts a character back.
To be continued ......
[Disclaimer:
1) This content may come from the Internet, or I have sorted it out by myself. It only represents the opinions and opinions of the Internet and individuals!
2) This content is for reference only. Any reference to this content will cause any consequences and will be irrelevant to the original author and the author of this blog !]