[example 1]
#include <stdio.h>
int main(int argc,char*argv[])
{
int i = 0;
for(i=1;;i++)
{
printf("\r for loop rounds: %d test", i);
fflush(stdout);
sleep(1);
}
for(i=1;;i++)
{
printf("\r for loop rounds: %d test", i);
fflush(stdout);
sleep(1);
}
}
[example 2]
#include <stdio.h>#define COLOR_FG_BLACK 30
#define COLOR_FG_RED 31
#define COLOR_FG_GREEN 32
#define COLOR_FG_YELLOW 33
#define COLOR_FG_BLUE 34
#define COLOR_FG_PURPLE 35
#define COLOR_FG_DGRN 36
#define COLOR_FG_WHITE 37
#define COLOR_BG_BLACK 40
#define COLOR_BG_DRED 41
#define COLOR_BG_GREEN 42
#define COLOR_BG_YELLOW 43
#define COLOR_BG_BLUE 44
#define COLOR_BG_PRUPLE 45
#define COLOR_BG_DGRN 46
#define COLOR_BG_WHITE 47
#define COLOR_DEFAULT 0
#define CURSOR_BACK_A_LINE "\33[1A"
int main(int argc,char*argv[])
{
int i = 0;
printf("\n");
for(i=1;;i++)
{
printf(CURSOR_BACK_A_LINE"for loop rounds: \033[%d;%dm %d \033[%dm test\n",COLOR_FG_RED,COLOR_BG_YELLOW,i,COLOR_DEFAULT);
/* printf("\33[1A" "\33[34;43m %d \33[0m \n",i);*/
sleep(1);
}
}
[other]
refer to ncurses