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
Asked
Active
Viewed 174 times
-5
-
Please be more specific. For example, output to where? – MikeCAT Jul 10 '16 at 08:24
-
Try using system("cls") or system("clear") (depending on your OS) to clear the screen after printing each number. – Mattia F. Jul 10 '16 at 08:32
-
[Possible duplicate](http://stackoverflow.com/questions/2732292/setting-the-cursor-position-in-a-win32-console-application) – Ivan Rubinson Jul 10 '16 at 08:34
2 Answers
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