Results 1 to 5 of 5

Thread: Updating one part of the output (C++ / Cout)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    9
    Thanked 29 Times in 29 Posts

    Default Re: Updating one part of the output (C++ / Cout)

    For completions sake:

    Qt Code:
    1. #include <iostream>
    2. using namespace std;
    3.  
    4. int main() {
    5. for (uint i = 0; i <= 100; ++i) {
    6. cout << "\rProgress: " << i << "%" << flush;
    7. for (uint j = 0; j < 9999999; ++j); // pause
    8. }
    9.  
    10. cout << endl;
    11.  
    12. return 0;
    13. }
    To copy to clipboard, switch view to plain text mode 

    \r means carriage return. Without a \n, it just takes the cursor back to the beginning of the current line. flush flushes the buffer.
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

  2. #2
    Join Date
    Oct 2007
    Location
    USA
    Posts
    27
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    1

    Default Re: Updating one part of the output (C++ / Cout)

    Alright, thanks all.... Its nice to fill in one of those little gaps of knowledge.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.