delorie.com/archives/browse.cgi | search |
From: | "Tim" <t DOT j DOT _no_spam AT btinternet DOT com> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: does kbhit() works outside <PC.H> ??? |
Date: | Sat, 15 Mar 2003 09:23:39 +0000 (UTC) |
Organization: | BT Openworld |
Lines: | 92 |
Message-ID: | <b4urer$h6o$1@venus.btinternet.com> |
References: | <ea10a10d62eaa7aea05133d2c5488823 DOT 113557 AT mygate DOT mailgate DOT org> |
NNTP-Posting-Host: | host217-39-45-113.in-addr.btopenworld.com |
X-Trace: | venus.btinternet.com 1047720219 17624 217.39.45.113 (15 Mar 2003 09:23:39 GMT) |
X-Complaints-To: | news-complaints AT lists DOT btinternet DOT com |
NNTP-Posting-Date: | Sat, 15 Mar 2003 09:23:39 +0000 (UTC) |
X-Newsreader: | Microsoft Outlook Express 6.00.2720.3000 |
X-MSMail-Priority: | Normal |
X-Priority: | 3 |
X-MimeOLE: | Produced By Microsoft MimeOLE V6.00.2600.0000 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
Helen The function kbhit() is not stored in pc.h header file, that is just where its prototype is located. The function itself is in one of the djgpp libraries which automatically gets linked into your project when you compile. A prototype is just used to tell the compiler what parameters are needed in order to call to a function that is not part current source file*. If no prototype is available the compiler will just assume that the function will accept and return integers and build the code accordingly. If you set the compiler directive -Wmissing-prototypes it would have warned you that you had no prototype for the kbhit() function. Headers also include macros and constants that are related to the various functions the it represents. kbhit() is such a simple function that you were able to use it with out any problems, but if you had tied to use something like settime() without the header file you would have found that the compiler would not be able to compile because it would not have any information about the required data structure associated with that function. I hope this helps a little, * This is by no means a complete explanation and a read of a 'C' programming guide should fill in the gaps. Tim "helen" <lab_darzo AT libero DOT it> wrote in message news:ea10a10d62eaa7aea05133d2c5488823 DOT 113557 AT mygate DOT mailgate DOT org... > > I have DJGPP on win98 and win2k > > if I write the following: > > ---- > #include <stdio.h> > /* DO-WHILE */ > int main() > { > int x=0; > > do { > x=x+1; > printf("%5d",x); > rest(100); > } while (!kbhit()); > > return 0; > } > ---- > > I wouldn't expect it to work (isn't kbhit() defined in <pc.h> ?) > but IT WORKS INSTEAD ! > > also if I add > #include <conio.h> > > it also works and I do not need to use > _conio_kbhit() > > other functions defined in conio.h also work, even if I don't include > the conio.h !! > Like: > clrscr(), or textcolor(); and also rest(); > > how do you explain that ? > > > helen (for once it works MORE than I need it to!!) > > > -- > Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |