Clearing output of a terminal program Linux C/C++

Viewed 48336

I'm interested in clearing the output of a C program produced with printf statements, multiple lines long.

My initial guess was to use

 printf("output1\n");
 printf("output2\n");
 rewind(stdout);
 printf("output3\n");
 printf("output4\n");

but this produces

 output1
 output2
 output3
 output4

I was hoping it would produce

 output3
 output4

Does anyone know how to get the latter result?

7 Answers
Related