Click to See Complete Forum and Search --> : cout>>endl
Vlatko
Sep 9th, 2000, 12:53 PM
Can someone explain what are
cout and endl
and what are they used for.
parksie
Sep 9th, 2000, 01:10 PM
In C++, I/O is done using streams. cout is a variable of type ofstream that is bound to the standard file stdout. This means, basically, that any output sent to cout appears on the console:
cout << "Here is a string";
endl is actually a function, that adds a newline, then flushes the buffer. It's effectively:
cout << "String" << endl;
equals:
cout << "String" << "\n";
cout.flush();
There are also streams called cin (stdin), and cerr (stderr).
V(ery) Basic
Sep 9th, 2000, 01:13 PM
#include <iostream.h>
int main()
{
cout << "Hello" << endl;
cout << "World!" << endl;
cout << "\n";
cout << "OR without endl";
cout << "\n";
cout << "Hello";
cout << "World!";
return 0;
}
endl makes the next thing added on a new line
/n has the same effect except it has to be part of a string
cout displays text in a console window. It has to be followed by << and then the string
int decared_variable
cin >> declared_variable
waits for the user to enter a value (in this case a long integer)
I hope this helps,
Me.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.