I would like to know if there is a way in C to overwrite an existing value that has already been printed instead of creating a new line every time or just movin
Refer to the sample code to understand:
#include
#include
void myThread(void* ptr) {
printf("Hello in thread\n");
int i=0;
for(;i<10;i++)
{
sleep(1);
printf(". ");
fflush(stdout); //comment this, to see the difference in O/P
}
printf("sleep over now\n");
}
int main(void) {
pthread_t tid;
printf("creating a new thread\n");
pthread_create(&tid, NULL, (void*)myThread, 0);
printf("going to join with child thread..\n");
pthread_join(tid, NULL);
printf("joined..!!\n");
return 0;
}
Reference Blog