Thread: Overwriting last print statement in command line

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    2

    Overwriting last print statement in command line

    Hi,

    I would like to know how to print to the command line but overwriting the last line.
    For example I want to print numbers 1 to 10 using a loop in a way that there is only one print statement to the command line and only the number changes as it loops from 1 to 10.

    Kind of like a progress counter.

    Thanks

  2. #2
    -AppearingOnThis..........
    Join Date
    May 2005
    Location
    Netherlands
    Posts
    44
    You could use the backspace char ('\b') to erase the previous character on the line.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    you could also clear screen if you want to do that.. however the command you use i believe will be OS-specific, ie: system("cls"); for windows

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. merging linked lists
    By scwizzo in forum C++ Programming
    Replies: 15
    Last Post: 09-14-2008, 05:07 PM
  2. Usefulness of the "else if" statement
    By gn17 in forum C Programming
    Replies: 7
    Last Post: 08-12-2007, 05:19 AM
  3. Bypassing Print Dialog Box
    By leojose in forum Windows Programming
    Replies: 0
    Last Post: 10-13-2005, 06:44 AM
  4. Scope And Parameter Passing
    By djwicks in forum C Programming
    Replies: 6
    Last Post: 03-28-2005, 08:26 PM
  5. Uh-oh! I am having a major switch problem!
    By goodn in forum C Programming
    Replies: 4
    Last Post: 11-01-2001, 04:49 PM