The function of the cin.get(ch) function is to read a single character from the standard input and store it in the character variable ch. 1. Read a character from standard input and store it in ch. 2. Return the ASCII code of the character read. 3. If the input stream reaches the end of file, return EOF.
cin.get(ch) function function
cin.get(ch) is in the C standard library Member function of the input stream object (cin) that reads a single character from standard input and stores it in the specified character variable ch.
How it works
When cin.get(ch) is called, it will:
If the input stream has reached the end of the file, cin.get(ch) returns EOF (end of file flag).
Usage
cin.get(ch) is often used to read a single character from the standard input, for example:
<code class="c++">char ch; cin.get(ch);</code>
The above code reads from the standard input Reads a character from and stores it in the ch variable.
Note
The above is the detailed content of Function of cin.get(ch) function in c++. For more information, please follow other related articles on the PHP Chinese website!