[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

getting input not working

From: Peter Jay Salzman
Subject: getting input not working
Date: Mon, 3 Mar 2003 19:25:31 -0800
User-agent: Mutt/1.4i

hi there,

this is ncurses on debian testing.

my program takes words from stdin and orders them into a binary tree.
very similar to "self referential structures" from kernighan/ritchie's
"the C programming language" (pg 139).  like:

a.out < file_of_words

after the words are ordered into a binary tree, i'm using ncurses to
print the tree.

here's (very) pared down ncurses code:

void ncurses_print_tree(struct node *node_ptr)
   WINDOW *win;
   int c = 65;


   win = newwin(0, 0, 0, 0);

   while ( 1 )
      c = wgetch(win);
      mvwprintw(win, 0, 0, "%c", c);


i expect my keystrokes to be displayed in the upper left corner of the
xterm.  instead, all that's being displayed is "-1".  this is "ERR", as
defined in ncurses.h.

i check win for NULL, and i'm able to mvwprintw() stuff to the screen.
it looks like the program isn't "waiting" to collect my input.

i'm wondering if i've somehow "ruined" stdin by collecting input on
stdin.  i've tried using fflush(stdin) to make sure there's nothing
there, but still no success.

when i debug the program, gdb steps over getch() as if it weren't there.

any idea why collecting input may be failing?


First they ignore you, then they laugh at you, then they fight you,
then you win. -- Gandhi, being prophetic about Linux.

Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D

reply via email to

[Prev in Thread] Current Thread [Next in Thread]