Results 1 to 3 of 3

Thread: cout>>endl

  1. #1

    Thread Starter
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Can someone explain what are
    Code:
    cout and endl
    and what are they used for.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  3. #3
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    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.
    Courgettes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width