Clear the output screen

The output screen tends to get a little cluttered, i tried the command
system("CLS")
But that doesnt seem to do the trick (when it runs it says it cant find CLS or something) is there any other ways to manage this?
Yes. Try using the function
clrscr();
it is declared in the conio.h header-file
closed account (z05DSL3A)
jpotts,

What OS are you using?

See: Clear the screen
http://www.cplusplus.com/articles/4z18T05o/
Hey,
I use Ubuntu, so does that mean i would use

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <unistd.h>
#include <term.h>

void ClearScreen()
  {
  if (!cur_term)
    {
    int result;
    setupterm( NULL, STDOUT_FILENO, &result );
    if (result <= 0) return;
    }

  putp( tigetstr( "clear" ) );
  }


and make that a seperate function in my code?
Yes. Don't forget to link with the proper library (probably one of -lcurses, -lncurses, or -lterminfo).
None of those h files are working. When you say link with the proper library you mean put #include <lcurses> or something right? If not what should i do?
No. Linking is done by the linker. #include takes effect at the pre-compilation stage. Your IDE probably has a little box somewhere for you to type in libraries to link against.
If you are using Ubuntu I'm going to assume you're using Code::Blocks as your IDE. To link to a library go to "Project -> Build Options -> Linker Settings -> Add" Then navigate to the lib file you are trying to link.
Ubuntu does not come with libcurses installed by default. You will probably also have to install it before you can use it.

One simple way is to use
apt-get install ncurses-dev
at the command prompt.
That didnt work... is there a way to get them for Geany (the compiler i use)?
The same library gets installed. You have to configure Geany to link against libcurses.
I don't know how to do that, but I suspect they do over here:
http://www.geany.org/manual/current/index.html
i couldnt figure out how to get it done... I just ended up using the bad method of clearing the screen:

1
2
3
4
5
6
  void ClearScreen()
    {
    int n;
    for (n = 0; n < 5; n++)
      printf( "\n" );
    }


Thankyou for all the advice though :)
Topic archived. No new replies allowed.