Which C++ output stream function is used to write a single character to the output stream?
Options
- A. put()
- B. get()
- C. peek()
- D. More than one of the above
- E. None of the above
Quiz Practice:
A. put()
Answer: (A) put()
The put() function of an output stream is used to write a single character.
Example:
cout.put('A');
This statement writes the character A to the standard output.
A useful comparison is:
cin.get() → reads a character
cout.put() → writes a character