There are several methods to clear the console or output screen and one of them is clrscr() function. It clears the screen as function invokes. It is declared in “conio. h” header file.
You can use Ctrl+L keyboard shortcut in Linux to clear the screen. It works in most terminal emulators.
If you want to clear the console screen in C, you'll want to use system("clear") for Linux and macOS, or system("cls") for Windows.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With