Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I clear the screen in C? [duplicate]

Tags:

c

unix

macos

I want to clear all the text that is on the screen. I have tried using:

#include <stdlib.h>
sys(clr);

Thanks in advance! I'm using OS X 10.6.8. Sorry for the confusion!

like image 654
user2651382 Avatar asked Nov 29 '22 12:11

user2651382


1 Answers

You need to check out curses.h. It is a terminal (cursor) handling library, which makes all supported text screens behave in a similar manner.

There are three released versions, the third (ncurses) is the one you want, as it is the newest, and is ported to the most platforms. The official website is here, and there are a few good tutorials.

#include <curses.h>

int  main(void)
{
     initscr();
     clear();
     refresh();
     endwin();
}
like image 187
Jiminion Avatar answered Dec 05 '22 02:12

Jiminion