Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!uunet!proto!joe From: joe@proto.com (Joe Huffman) Newsgroups: comp.os.msdos.programmer Subject: Re: help need in C Message-ID: <1991Apr15.035130.26710@proto.com> Date: 15 Apr 91 03:51:30 GMT References: <7339@munnari.oz.au> Organization: Prototronics @ Sandpoint, Idaho Lines: 41 ksiew@ecr.mu.oz.au (Kok-Hsien SIEW) writes: > On Turbo Pascal 5.5 I could write the following code: > > repeat > do_calculations; > until keypressed; > inchar:=readkey; > writeln('The key you pressed is ',inchar); > > But how do I do this in Turbo C and Unix C? Under Zortech C (both the MSDOS and SCO UNIX version) this can be written as: #include #include void do_calculations(void) { printf("Hello world... 2 + 2 = %d\n", 2 + 2); } int main(int argc, char *argv[]) { int inchar; do { do_calculations(); } while(!kbhit()); inchar = getch(); printf("The key you pressed is '%c' (0x%x)\n", inchar, inchar); return 0; } -- joe@proto.com