0Pricing
C++ Academy · Lesson

Working with std::cerr and std::clog

Separate diagnostics and logs from program output using cerr and clog streams.

Three Output Streams

The standard library exposes three predefined output streams:

  • std::cout — buffered standard output
  • std::cerr — unbuffered standard error
  • std::clog — buffered standard error

std::cerr: Errors and Warnings

std::cerr writes to stderr and is unbuffered — output appears immediately, even if the program crashes next.

std::cerr << "Error: file not found\n";

All lessons in this course

  1. Using std::cin and std::cout Properly
  2. Formatting Output with iomanip
  3. Reading Input Safely with getline
  4. Working with std::cerr and std::clog
← Back to C++ Academy