iostream - STL C++

cerr

Declaration

extern ostream cerr;

Description

The cerr object is an instantiation of the output stream ostream that controls the stream buffer and is used to output error messages.

Header Include

#include <iostream>

Example

#include <iostream>

int main() {
	using namespace std;

	// We can send any content to cerr, just like cout
	cerr << "XoaX.net" << endl;

	// However, we usually reserve cerr for error messages
	cerr << "An error has occured" << endl;

	// Keep the window open
	cin.get();
	return 0;
}

Output

cerr Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.