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

5.4 clog (log stream)

1 min read

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 clog is buffered. This means that each insertion to clog could cause its output to be held in a buffer until the buffer is filled or until the buffer is flushed.

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

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

You would not be able to see any difference in cout, cerr and clog with these small examples, but while writing and executing big programs then difference becomes obvious. So this is good practice to display error messages using cerr stream and while displaying other log messages then clog should be used.

                      6.1 Conditional branching - if          NEXT >>

You may like these posts

  • auto The default class. Automatic variables are local to their block. Their storage space is reclaimed on exit from the block. register If possible, the variable will be…
  • Array is a fixed size collection of similar data type items. Arrays are used to store and access group of data of same data type. Arrays can of any data type. Arrays must…
  •   An operator is a symbol. Compiler identifies Operator and performs specific mathematical or logical operation. C provides following operators : # Arithmetic Operators # L…
  • /* This Program prints Hello World on screen */ #include <iostream.h> using namespace std; int main () { cout << "Hello World!"; return 0; } 1 . /* This program ..…
  • refers to where variables is declared. It can be Inside a function or a block which is called local variables, In the definition of function parameters which is called f…
  •    A variable in C++ is a name for a piece of memory that can be used to store information. There are many types of variables, which determines the size and la…

Post a Comment