How can I make the cursor step backwards?

This is a discussion on How can I make the cursor step backwards? within the C Programming forums, part of the General Programming Boards category; Hello, I want to have my program display a progress indicator. It should look like this (but all on one ...

  1. #1
    C Seņor
    Guest

    How can I make the cursor step backwards?

    Hello, I want to have my program display a progress indicator. It should look like this (but all on one line):

    Booting.
    Booting..
    Booting...
    Booting.
    Booting..
    Booting...

    See how the periods go 1, 2, 3, and then start back at 1? How can this be done?

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Use \b to move the cursor backwards. Overtype previous characters using a space.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    C Seņor
    Guest
    Thanks a lot!

  4. #4
    Registered User
    Join Date
    Sep 2002
    Posts
    9
    You can also use the gotoxy(x,y) function to go to a specific cell on the screen. I think that's in conio.h

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by smartperson
    You can also use the gotoxy(x,y) function to go to a specific cell on the screen. I think that's in conio.h
    You could if you have it in your compiler and are running on the correct OS. The \b solution is a little more generic, even if it is ugly!
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  6. #6
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    how about this:

    char *buf[] = {"Booting. ", "Booting.. ", "Booting..."};
    for (int i = 0; i < 100; i++) {
    cout << buf[i%3] << '\r' << flush;
    Sleep(1000); // or whatever (does Sleep take milliseconds?)
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to make a Packet sniffer/filter?
    By shown in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2009, 09:51 PM
  2. HELP!wanting to make full screen game windowed
    By rented in forum Game Programming
    Replies: 3
    Last Post: 06-11-2004, 05:19 AM
  3. make all rule
    By duffy in forum C Programming
    Replies: 9
    Last Post: 09-11-2003, 02:05 PM
  4. Question about atheists
    By gcn_zelda in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 08-11-2003, 12:50 PM
  5. Replies: 6
    Last Post: 04-20-2002, 07:35 PM

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