Integer input
John Kasdan
kasdan at cunixd.cc.columbia.edu
Fri Oct 27 12:54:04 AEST 1989
I have been trying to write an encryption program which
accepts an integer as a key. It seemed like a good idea to
turn off echoing while the key is entered, so I decided to
use curses. The problem is, I don't seem to be able to enter
an integer from the keyboard in any reasonable way. scanf
behaves badly on non-numeric data, and even worse on integers
bigger than the maximum size allowed. So I thought I would use
getch() to put the input into a buffer and then use sscanf.
The trouble is, getch() doesn't give any indication of the
end of the input. No \n or \0 or EOF. Nothing. getc() does,
but it doesn't work with curses.
The system I'm working on is VMS C. Is this problem unique
to that environment? I could, of course, use DCL to turn off
echoing, but I was trying for a little more portability. The
tentative solution I'm using is getstr() and, to avoid the
Robert Morris problems, buffers the size of MAXBUF, the largest
allowable line, which is 2K. Pretty ugly. Anyone know a
better way?
_________________
/KAS
John Kasdan internet: kasdan at cunixd.cc.columbia.edu
Columbia University, bitnet: kasdan at cunixC.cc.columbia.edu
School of Law uucp:
435 West 116th St. {rutgers,seismo,topaz}!columbia!cunixd!kasdan
New York, NY 10027
_________________
"Life is like an analogy", anonymous project leader.
More information about the Comp.lang.c
mailing list