newline

This is a discussion on newline within the C++ Programming forums, part of the General Programming Boards category; Hi, I'm new to C++. Anyway, what's the point of using endl when you can use \n?...

  1. #1
    Un Artiste Extraordinaire volk's Avatar
    Join Date
    Dec 2002
    Posts
    357

    Question newline

    Hi, I'm new to C++. Anyway, what's the point of using endl when you can use \n?

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    run a search.

    click here your search is done for you.

  3. #3
    Un Artiste Extraordinaire volk's Avatar
    Join Date
    Dec 2002
    Posts
    357
    That raises some new questions: what's the point of typing std::cout instead of cout?

    Also, what does "flushes the output buffer" mean?

  4. #4
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    >Also, what does "flushes the output buffer" mean?

    Flushing the output buffer empties the buffer onto the screen.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>what's the point of typing std::cout instead of cout?
    http://faq.cprogramming.com/cgi-bin/...&id=1043284351

    >>what does "flushes the output buffer" mean?
    Output from your program can sometimes be buffered before it is actually displayed on the screen, or written to the file (depending on where it's going). Using a flush routine tells the OS to move the data from the buffer to its destination now, rather than letting the OS decide when to do it for you.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  6. #6
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    now, rather than letting the OS decide when to do it for you.
    Yeah, I've had information displayed in the wrong sequence, or even wait until main() ends before it was displayed. This was when using \n in a windows console application.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newline characters
    By xRandyx in forum C Programming
    Replies: 3
    Last Post: 11-15-2005, 10:01 AM
  2. how to remove newline from a string
    By rupurt in forum C Programming
    Replies: 8
    Last Post: 10-01-2005, 06:01 PM
  3. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 09:46 AM
  4. fgets and a bothersome newline char
    By ivandn in forum Linux Programming
    Replies: 1
    Last Post: 11-14-2001, 12:41 PM
  5. newline / memset
    By frenchfry164 in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 10-31-2001, 12:21 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21