progress of a function in c

Discussion in 'OT Technology' started by mobbarley, Aug 28, 2008.

  1. mobbarley

    mobbarley Active Member

    Joined:
    Mar 4, 2005
    Messages:
    9,256
    Likes Received:
    2
    Location:
    Sydney
    I am writing a small app in c for linux and want it to show something like:
    Progress: 0%
    while it is working. Can I update the 0% without causing another line or (hopefully) having to rewrite the other text on that line?
     
  2. skinjob

    skinjob Active Member

    Joined:
    Jan 6, 2001
    Messages:
    2,337
    Likes Received:
    0
    Location:
    Aztlán
    If the "Progress: 0%" is on a line by itself, try printing a carriage return character at the end.

    printf("Progress: %d%\r", p);
     
  3. mobbarley

    mobbarley Active Member

    Joined:
    Mar 4, 2005
    Messages:
    9,256
    Likes Received:
    2
    Location:
    Sydney
    perfect, looks like I can use tabs to space the data easily too. thank you!
     

Share This Page