+ 3

What is the difference between cout,cerr and clog?

<iostream> Library `.

25th Aug 2017, 6:07 PM
ziad hany
ziad hany - avatar
2 Answers
+ 5
Most operating systems define three streams, for sending data to and from the program. There is stdin, for getting data (in C++ you use cin for that), then theres stdout, for writing data (in C++ you use cout for that), and stderr for writing errors (in C++ you use cerr for that). By default, if you just run your program, both stdout and stderr stuff will be printed to the console, but you can redirect these streams and you'll see the difference. Write some code that writes to cout and cerr, compile it, and in the console run: ./myprogram.exe 1> stdout.txt 2> stderr.txt And you'll see different things landing in those two files. clog points to stderr by default, but you can redirect that inside C++ to a file for example, which is useful for debugging or development.
25th Aug 2017, 6:20 PM
Schindlabua
Schindlabua - avatar
+ 1
cout for print the string. cerr for store the our 3 dimensions array data to another register . and clog is used to get the location of 3 dimension array store on another register
26th Aug 2017, 2:40 AM
ADESH KUMAR UPADHYAY
ADESH KUMAR UPADHYAY - avatar