title: Clear() function in curses.h library
body: <p>I'm doing school assignments. Writing a simple command line interpreter. One of the functions is to clear screen. Its is called cmd_clr. For that, I'm trying to use clear() function from curses.h library. The problem is clear() returns -1 value, for some reason. Here is the code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;  /* Standard IO functions */
  #include &lt;string.h&gt; /* String library, might be useful */
  #include &lt;dirent.h&gt; /* Directory entry API */
  #include &lt;curses.h&gt; /* Useful for screen control */
  #include &lt;unistd.h&gt; /* Process management API */
  
  /* Global constants */
  #define true    1
  #define false   0
  
  /* Global variables, structures */
  char  pwd[512];  
  char  shell[512];
  
  void cmd_dir(char []);
  void cmd_cd(char []);
  void cmd_clr(void);
  
  int main (void)
  {
     char prompt[512] = {":#"};
  
  char    command[512];
  char    temp[512];
  char*   token;
  
  while (true)
  {
  
  
  /* Print command prompot, including PWD */
  printf("%s%s ", pwd, prompt);
  
  /* Get command input */
  gets(command);
  
  /* Isolate the command token */
  strcpy(temp, command);
  
  token = strtok (temp, " ");
  
  
  void cmd_dir(char directory[])
  {
  printf("shell command: dir\n");
  token = strtok(NULL, " "); //to get the directory
  execlp("/bin/ls","ls", "-l", token, NULL);
  
  }
  
  void cmd_cd(char directory[])
  {   
  
      printf("shell command: cd\n");
      token = strtok(NULL, " "); //to get the directory
      chdir(token);
      system("pwd");//to print the current directory
  
  }
  
  void cmd_clr(void)
  {     
      printf("shell command: clr\n");
      int tv = clear();
      printf("%d", tv);
  
  }
  
  
  
  if (strcmp(token, "dir") == 0)
  {
    cmd_dir(command);
  }
  else if (strcmp(token, "cd") == 0) 
  {
    cmd_cd(command);
  } 
  
  else if (strcmp(token, "clr") == 0)
  {
    cmd_clr();
  }
  
  
  
  }
  }
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>mekhron@ubuntu:~/folder4$ gcc -o test test.c -lncurses
  mekhron@ubuntu:~/folder4$ ./test
  :# clr
  shell command: clr
  -1:# ^C
  mekhron@ubuntu:~/folder4$ 
  </code></pre>