User Dialog
donl mathis
donl at glass.wpd.sgi.com
Wed Sep 13 10:07:33 AEST 1989
In article <41627 at sgi.sgi.com>, thant at horus.sgi.com (Thant Tessman) writes:
> > char input[15];
> >[...]
> > qread( input[ charCount ] );
> Change to either:
> qread( &input[charCount] );
> or:
> qread( input + charC );
Closer, but it doesn't seem quite right. Qread's argument is supposed to
be the address of a short, not a character. I'm too tired to figure out
which half of the short the character is in and which neighboring character
gets trashed, but it seems like a bad idea in any case.
It might also be wise to check that (qread() == KEYBD) before you assume
that you're getting a character. Here's my best guess, without echoing...
#include <gl.h>
#include <device.h>
main ()
{
char buff [128], *p;
short dev, ch;
winopen ("temp");
qdevice (KEYBD);
p = buff;
while (dev = qread (&ch)) {
if (dev == KEYBD) {
if (ch == '\n' || ch == '\r') {
break;
}
*p++ = ch;
}
}
*p = '\0';
printf ("%s\n", buff);
gexit ();
exit (0);
}
--
- donl mathis at Silicon Graphics Computer Systems, Mountain View, CA
donl at sgi.com
More information about the Comp.sys.sgi
mailing list