getting input from keyboard
David Doll
davidd at wolf.cs.washington.edu
Mon Dec 31 14:55:11 AEST 1990
Hello,
Inside of some "C" code, I want to be able to get a single char(or
number) from the user without them having to type a carriage return. For
example:
crunch,crunch, etc.
prompt user for some letter, have them hit "y" and then more
crunch, etc.
Heres a segment of code I tried:
--------------------------------------------------------
#include <stdio.h>
#include <curses.h>
/*
to compile: cc -o run test.c -lcurses -ltermcap
*/
main()
{
int ch;
int i;
cbreak();
for (i=0; i<10; i++){
ch=getchar();
putchar(ch+1);
putchar('\n');
}
nocbreak();
}
-------------------------------------------------------
but when I run "run" it accepts the char but at the end (at the end of the for
loop), it frezzes up the keyboard...I'm sure this is simple but I'm missing
what's in front of me :) Could you e-mail me and I'll post a summary if
theres interest. Thanks for the help and wisdom, I appriciate it.
--
David Doll
Computer Science Dept.
University of Washington
Seattle, WA 98195
M/S: FR-35
davidd at wolf.cs.washington.edu
More information about the Comp.lang.c
mailing list