Thread: Just a little question.

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    4

    Question Just a little question.

    what does endl mean? i've seen it like this:

    cout<<"hello"<<endl; i'm guessing i means end line.. but i'm not sure

    i would right the above code like this:

    cout<<"hello";

    is the endl more proper?

    thanks a bunch

    -jumbo-shrimp

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    endl prints a newline character and flushes the stream.
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    i would right the above code like this:

    cout<<"hello";

    is the endl more proper?
    You could write the code like that, but then any subsequent output would be on the same line. If instead you want output to continue on a newline, you need to do write an additional instruction for that.

    It's more efficient to use '\n' like this:

    cout<<hello'\n';

    but at this point in your C++ learning, don't wouldn't worry about it: use endl or '\n' if you want output to continue on a newline.

  4. #4
    *this
    Join Date
    Mar 2005
    Posts
    498
    not to be a butt, but i believe it would be
    Code:
    cout << "hello\n";
    not
    Code:
    cout << hello'\n';
    because your code could be used for a string, if its predefined, but then you would have to add it after the string before output im not sure you can do it that way exactly.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM