std::endl;

This is a discussion on std::endl; within the C++ Programming forums, part of the General Programming Boards category; I am fiddling with C++, and I was wondering if there is an equivalent for the C fflush(stdout) without using ...

  1. #1
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528

    std::endl;

    I am fiddling with C++, and I was wondering if there is an equivalent for the C fflush(stdout) without using std::endl? As an example I am doing some really basic i/o stuff, in order to get my feet wet:

    Code:
        std::cout << "\nThis program raises a number to a power:" << std::endl;
        std::cout << "\nEnter the base number: ";  // I don't want the newline from endl here
    But I do want to flush the buffer.

    ~/

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Try std::flush
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528
    Ah - that sounds reasonable. Thanks.

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    std::cout.flush() as well.

  5. #5
    aoeuhtns
    Join Date
    Jul 2005
    Posts
    581
    If you're going to be asking for input next, you don't need to manually flush the buffer. Using std::cin will flush it.

Popular pages Recent additions subscribe to a feed

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