title: Ncurses and Resizing window
body: <p>I tried to enter text at the bottom of window and print it on the top. I did this. But when I resize the window, cursor is attached to the bottom of the window and when I type the text, symbols do not echo on the screen. How fix it?</p>
  
  <p>Sorry for my English.</p>
  
  <p>my code: </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include &lt;ncurses.h&gt;
  #include &lt;termios.h&gt;
  #include &lt;sys/ioctl.h&gt;
  #include &lt;signal.h&gt;
  
  WINDOW* txt_win;
  WINDOW* msg_win;
  
  
  void sig_winch(int in) {
  
      struct winsize size;
      ioctl(fileno(stdout), TIOCGWINSZ, (char*) &amp;size);
      resizeterm(size.ws_row, size.ws_col);
      // wprintw(msg_win,"%i, %i", LINES, COLS);
      // wmove(msg_win, 0, 0);
      // wresize(msg_win, LINES - 4, COLS);
      wrefresh(msg_win);
      // mvcur(LINES - 3, 0, LINES - 3, 0);
      // setsyx(LINES - 3, 0);
      // wmove(txt_win, LINES - 3, 0);
      // wresize(txt_win, 3, COLS);
      wrefresh(txt_win);
      echo();
  
     }
  
  int main() {
  
          int x = LINES - 1;
          int y = 0;
  
          if (!initscr())
          {
              fprintf(stderr, "Error initialising ncurses.\n");
              exit(1);
          }
  
          signal(SIGWINCH, sig_winch);
  
          initscr();
          curs_set(1);
          refresh();
  
          char str[256];
                      //   dy   dx         y         x
          msg_win = newwin(LINES - 4, COLS, 0, 0);
          txt_win = newwin(3, COLS,       LINES - 3, 0);
          keypad(txt_win, 1);
  
          int line = 0;
          while (1) {
  
              wrefresh(txt_win);
              curs_set(1);
              if (wgetnstr(txt_win, str, 256) == 0) {
                  wclear(txt_win);
                  curs_set(0);
                  waddstr(msg_win, str);
                  wrefresh(msg_win);
              }
          }
  
  
      getch();
  
      delwin(txt_win);
      delwin(msg_win);
  
      endwin();
  }
  </code></pre>