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

Correct Answer (Detailed Explanation is Below)

A. put()

Detailed Explanation

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