[Solved] C++ Overwrite output numbers in a For loop.


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

solved C++ Overwrite output numbers in a For loop.