Overwriting last print statement in command line

This is a discussion on Overwriting last print statement in command line within the C Programming forums, part of the General Programming Boards category; Hi, I would like to know how to print to the command line but overwriting the last line. For example ...

  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, 07: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, 03:49 PM

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