title: Cannot write to an ncurses window using mvwprintw()
body: <p>For days I'm trying to figure out the reason for the problem I have with this code:</p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;ncurses.h&gt;
  #include &lt;stdlib.h&gt;
  #include&lt;iostream&gt;
  using namespace std;
  
  WINDOW *create_newwin(int height, int width, int starty, int startx);
  void destroy_win(WINDOW *local_win);
  
  int main(int argc, char *argv[]) {  
      WINDOW *my_win;
      int startx, starty, width, height;
      int ch;
  
      initscr();              // Start curses mode        
      // cbreak();            // Line buffering en/disabled, pass on
                              // everything to me         
      keypad(stdscr, TRUE);   // I need that nifty F2
  
      height = 3;
      width = 10;
      starty = (LINES - height) / 2;  /* Calculating for a center placement */
      startx = (COLS - width) / 2;    /* of the window        */
      printw(&quot;Press F2 to exit!\n&quot;);
      refresh();
      my_win = create_newwin(height, width, starty, startx);
  
      // keypad(my_win, TRUE);
  
      while((ch = getch()) != KEY_F(2))   {   
          switch(ch) {    
              case KEY_LEFT:
                  destroy_win(my_win);
                  my_win = create_newwin(height, width, starty,--startx);
                  break;
              case KEY_RIGHT:
                  destroy_win(my_win);
                  my_win = create_newwin(height, width, starty,++startx);
                  break;
              case KEY_UP:
                  destroy_win(my_win);
                  my_win = create_newwin(height, width, --starty,startx);
                  break;
              case KEY_DOWN:
                  destroy_win(my_win);
                  my_win = create_newwin(height, width, ++starty,startx);
                  break;
              case 49:
                  // Kann nicht in das Fenster my_win ausgeben, Fkt.
                  // wird ignoriert:
                  mvwprintw(my_win, 1, 1, &quot;Value: %d, H %d, W %d, STy %d, STx %d&quot;, 1, height, width, starty, startx);
                  cout &lt;&lt; &quot;   cout -&gt; Values: height &quot; &lt;&lt;  height  &lt;&lt; &quot;, width &quot;&lt;&lt; width &lt;&lt;  &quot;, starty &quot; &lt;&lt; starty &lt;&lt;  &quot;, startx &quot; &lt;&lt; startx &lt;&lt; endl;
                  break;  
          }
      }
          
      endwin();           /* End curses mode */
      return 0;
  }
  
  WINDOW *create_newwin(int height, int width, int starty, int startx) {  
      WINDOW *local_win;
  
      local_win = newwin(height, width, starty, startx);
      box(local_win, 0 , 0);      // 0, 0 gives default characters 
                                  // for the vertical and horizontal
                                  // lines.
      wrefresh(local_win);        // Show that box.
  
      return local_win;
  }
  
  void destroy_win(WINDOW *local_win) {
      /* box(local_win, ' ', ' '); : This won't produce the desired
       * result of erasing the window. It will leave it's four corners 
       * and so an ugly remnant of window. 
       */
      wborder(local_win, ' ', ' ', ' ',' ',' ',' ',' ',' ');
      /* The parameters taken are 
       * 1. win: the window on which to operate
       * 2. ls: character to be used for the left side of the window 
       * 3. rs: character to be used for the right side of the window 
       * 4. ts: character to be used for the top side of the window 
       * 5. bs: character to be used for the bottom side of the window 
       * 6. tl: character to be used for the top left corner of the window 
       * 7. tr: character to be used for the top right corner of the window 
       * 8. bl: character to be used for the bottom left corner of the window 
       * 9. br: character to be used for the bottom right corner of the window
       */
      wrefresh(local_win);
      delwin(local_win);
  }
  </code></pre>
  <p>I took this from: <a href="https://tldp.org/HOWTO/NCURSES-Programming-HOWTO/windows.html" rel="nofollow noreferrer">https://tldp.org/HOWTO/NCURSES-Programming-HOWTO/windows.html</a>.</p>
  <p>Everything works as it should, with one exception:</p>
  <p>In the case statement <code>case 49:</code> which I added, I try to print in the window <code>my_win</code>, but the function call is ignored. It has no effect. Instead, the pressed key &quot;1&quot; is printed on the <code>stdscr</code>. The <code>cout</code> line is just for debugging purposes and is also printed at the current cursor position in <code>stdscr</code>.</p>
  <p>Any ideas what I'm doing wrong here? Or how to correct my possibly wrong understanding of the code?</p>
  <p>Thanks beforehand to everyone!</p>
  <p>Cheers!</p>