title: doing initscr() in a loop causes error initialisation
body: <p>I'm trying to make a simple ncurses program to display a box with messages. Im following this <a href="http://www.paulgriffiths.net/program/c/curwin1.php" rel="nofollow">link</a> and it works well. The problem that I'm having is that if I put the whole code in a function and call it in a loop, the initialisation is having an error. As far as I know, if I called <code>endwin()</code> at the end of the function, there shouldn't be any problem calling the <code>initscr()</code> again. Am I missing a function to enable the <code>initscr()</code> to be called again?</p>
  
  <p>This is the code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;curses.h&gt;
  
  int call()
  {
      WINDOW *mainwin, *childwin;
      int ch;
  
      if ((mainwin = initscr()) == NULL) {
              fprintf(stderr, "Error initialising ncurses.\n");
              exit(EXIT_FAILURE);
      }
  
      noecho();
      curs_set(FALSE);
  
      keypad(mainwin, TRUE);
  
      mvaddstr(childwin, 1, 6, "Warning! Press q to exit");
      mvaddstr(childwin, 2, 15, "{ OK }");
      refresh();
      while( (ch = getch()) != 'q') {
              refresh();
      }
  
      delwin(mainwin);
      endwin();
      refresh();
  
      return EXIT_SUCCESS;
  }
  
  int main()
  {
      int i;
  
      for (i=0;i&lt;10;i++) {
              call();
      }
  
      return 0;
  }
  </code></pre>
  
  <p><strong>EDIT:</strong> I've put the header file. Change the code to be more simpler</p>