0

I am using 'system("clear");' command to clean the output screen yet the last line printed is displayed.I am using Geany text editor using GNU gcc compiler.Please help and tell me clear the whole screen.

I am a college student and doing coding for the first time. Thanks in advance.

karel
  • 110,292
  • 102
  • 269
  • 299
user174621
  • 11
  • 1
  • 4
  • 1
    There was a discussion on terminal clear commands recently: http://askubuntu.com/questions/118523/whats-the-equivalent-of-the-cls-command-from-windows-dos. Try e.g. the `printf "\033c"` command. – Jos Aug 07 '14 at 22:54
  • 1
    Note that `\033c` and `\x1Bc` (ESC c) may be terminal specific. `system("tput clear")` may be a lot more portable. See `man 5 terminfo` for more, see also `man terminfo` for avoiding the overhead of system(). – Hannu Jan 04 '15 at 15:39

1 Answers1

0

system("clear") fails. Try using printf("\033c"). This works in geany.

amc
  • 7,022
  • 7
  • 39
  • 51
Sooraj
  • 1