|
-
Sep 9th, 2000, 12:53 PM
#1
Thread Starter
Frenzied Member
Can someone explain what are
and what are they used for.
-
Sep 9th, 2000, 01:10 PM
#2
Monday Morning Lunatic
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:
Code:
cout << "Here is a string";
endl is actually a function, that adds a newline, then flushes the buffer. It's effectively:
Code:
cout << "String" << endl;
equals:
Code:
cout << "String" << "\n";
cout.flush();
There are also streams called cin (stdin), and cerr (stderr).
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 9th, 2000, 01:13 PM
#3
Fanatic Member
Code:
#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
Code:
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|