Which of the following is the correct syntax to read the single character to console in the C++ language?
Options
- A. read ch()
- B. getlinech()
- C. get(ch)
- D. More than one of the above
- E. None of the above
Quiz Practice:
C. get(ch)
Answer: (C) get(ch)
In C++, a single character can be read using the get() function of the input stream.
For example:
char ch;
cin.get(ch);
Here, cin.get(ch) reads one character from the standard input stream and stores it in ch.
The functions read ch() and getlinech() are not valid standard C++ syntax for reading a single character.