How do I clear screen in g++
I've included curses and tried compile with lcurses as per gcc but fails, I can clear by using system("clear") but would prefer to use the curses library if possible.
How do I clear screen in g++
I've included curses and tried compile with lcurses as per gcc but fails, I can clear by using system("clear") but would prefer to use the curses library if possible.
In console mode, curses probably won't work, in X it should work just fine.
It sounds like you are in console mode so try this and see if it works:
#include <stdio.h>
#include <stdlib.h>
int main(){
char esc = 27;
printf("%c%s",esc,"[2J");
printf("%c%s",esc,"[1;1H");
return 0;
These are ANSI tty control codes, so-called "ANSI escape sequences" which you can google for.
did you try to use clrscr ?
call it with
clrscr();
it should work everywhere ...