Lorem ipsum dolor sit amet, consectetur adipiscing elit. Test link
Posts

5.3 cerr (error stream)

1 min read
Image result for cerr (error stream) C++


The predefined object cerr is an instance of iostream class. The cerr object is said to be attached to the standard error device, which is also a display screen but the object cerr is un-buffered and each stream insertion to cerr causes its output to appear immediately.

The cerr is also used in conjunction with the stream insertion operator as shown in the following example.
int main( )
{
char str[] = "Unable to read....";
cerr << "Error message : " << str << endl;
}

When the above code is compiled and executed, it produces the following result:
Error message : Unable to read....

                        5.4 clog (log stream)           NEXT >>

You may like these posts

  • The predefined object cerr is an instance of iostream class. The cerr object is said to be attached to the standard error device, which is also a display screen but the objec…
  •   A switch statement is used instead of nested if...else statements. It is multiple branch decision statement of C++. A switch statement tests a variable with list of val…
  • if statement An if statement contains a Boolean expression and block of statements enclosed within braces. Structure of if statement if (boolean expression ) /* if expression …
  •   while loop The while loop calculates the expression before every loop. If the expression is true then block of statements is executed, so it will not execute If the condi…
  • The predefined object clog is an instance of ostream class. The clog object is said to be attached to the standard error device, which is also a display screen but the object…
  • In most program environments, the standard input by default is the keyboard, and the C++ stream object defined to access it is cin. cin is an instance of iostream class For f…

Post a Comment