The iostream library can be used in a C++ program, but not in a C program. To use it, #include <iostream>.
cout << x
Write x to the standard output. What is written depends on the type of x. If x has type int, it will be written as a decimal integer. If x is type char, it will be written as a single character. |
cout << x << " " << y << "\n";
You can chain together several writes by writing << in front of each thing to be written. Be careful. If you do not write a space between items, no space will be shown. If you do not write and end-of-line character, no end-of-line will be written. |
cout << eol;
You can use eol to stand for "\n". |
cout << setwidth(n)
Set the format width for writing. For example, after doing this, an integer will be padded to n characters on the left with spaces. Use setwidth(0) to remove a format width. |
cout.getwidth()
This expression returns the current format width. It is useful to remember the old width so that you can restore it. |
cout.eof()
This is true if an attempt has been made to read something, but the attempt failed because there was nothing left in the file. |