title: ncurses inchstr function not working as intended?
body: <pre><code>#include &lt;curses.h&gt;
  #include &lt;fstream&gt;
  
  int main(){
  
      initscr();
      mvwprintw(stdscr, 1,1, "hello world");
      wmove(stdscr, 1,1);
  
      chtype* p = 0;
      int n = 0;
      n = winchstr(stdscr, p);
  
      std::ofstream test("test.txt");
  
      test &lt;&lt; n &lt;&lt; " " &lt;&lt; (p == nullptr);
  
      endwin();
  
  }
  </code></pre>
  
  <p>In the above I print <code>hello world</code>, move the cursor back to the start of the sentence, and attempt to store the contents of what is on screen in to <code>p</code> using <code>winchstr</code>. Except in the file <code>test.txt</code> I see only the output <code>-1 1</code> suggesting <code>p</code> was unchanged and <code>ERR</code> (i.e. -1) was returned, as the <a href="http://pdcurses.sourceforge.net/doc/PDCurses.txt" rel="nofollow">documentation</a> describes:</p>
  
  <blockquote>
    <p>int winchstr(WINDOW *win, chtype *ch);</p>
    
    <p>Description:
        These routines read a chtype or cchar_t string from the window, 
        starting at the current or specified position, and ending at the 
        right margin, or after n elements, whichever is less.</p>
    
    <p>Return Value:
        All functions return the number of elements read, or ERR on 
        error.</p>
  </blockquote>
  
  <p>Have I misunderstood the documentation? The contents of the line starting at <code>hello world</code> should be stored in the location pointed to by <code>p</code> after using <code>winchstr</code>  shouldn't it? Why is it returning error?</p>