-5

C++ Overwrite output numbers in a For loop. output = always 1 line of overwriting numbers counting up to 10. Basically LIVE number counting up. idk how to explain this ill show a .gif file to explain what i'm trying to do. http://images49.fotki.com/v1555/photos/2/292835/1608389/15animation-vi.gif

2 Answers2

1

the question needs further clarification but if you want to output numbers in a growing fashion to a console, you can use carriage return after each iteration and then sleep

the following example demonstrates how to do it in ubuntu using stdio and unistd:

#include<stdio.h>
#include<unistd.h>

int main()
{
    int i = 0;
    for(;i < 10; ++i)
    {
        printf("\b%d", i);
        fflush(stdout);
        sleep(1);
    }
}

hope this helps

monkeyStix
  • 620
  • 5
  • 10
0

I think SetConsoleCursorPosition is what you're looking for.

Ivan Rubinson
  • 3,001
  • 4
  • 19
  • 48