Article View: comp.os.msdos.programmer
Article #5768Re: help need in C
From: Joe Huffman
Date: Mon, 15 Apr 1991 03:51
Date: Mon, 15 Apr 1991 03:51
41 lines
1135 bytes
1135 bytes
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 <stdio.h>
#include <conio.h>
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
Technical Details
Message-ID:
<1991Apr15.035130.26710@proto.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!uunet!proto!joeReferences:
<7339@munnari.oz.au>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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