What I'm really trying to do is checking if the user has pressed a key without waiting for him to press a key. That's why I don't want to use the standard function "getc". If not necessary I would prefer not to use too much additional stuff like Windows API, ...
Isn't there a way just using standard C libraries or DOS or BIOS functions?
(I'm programing on and for a Windows98 System.)
Thanks for answers!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Do you mean for console?
<b>void</b> kbhit(<b>void</b>);
will do the trick.
It instantly checks for a key, which you can retrieve with <b>void</b> getch(<b>void</b>);
They are in conio.h but for some reason you
need to use conio_mingw.h with Dev-C++ and Mingw.
This prog seems to work better when compiled with Borland (and its conio.h)...
Sorry for this amount of questions!
What I'm really trying to do is checking if the user has pressed a key without waiting for him to press a key. That's why I don't want to use the standard function "getc". If not necessary I would prefer not to use too much additional stuff like Windows API, ...
Isn't there a way just using standard C libraries or DOS or BIOS functions?
(I'm programing on and for a Windows98 System.)
Thanks for answers!
>Isn't there a way just using standard C libraries or DOS or BIOS functions?
No
Do you mean for console?
<b>void</b> kbhit(<b>void</b>);
will do the trick.
It instantly checks for a key, which you can retrieve with <b>void</b> getch(<b>void</b>);
They are in conio.h but for some reason you
need to use conio_mingw.h with Dev-C++ and Mingw.
This prog seems to work better when compiled with Borland (and its conio.h)...
Tom vC
------------------------------------
#include <stdio.h>
#include <conio_mingw.h>
#include <time.h>
main() {
int keyhold, i = 0;
clock_t start, end;
double fps = CLK_TCK / 5;
/* 5 is the frames per second */
end = clock();
/* loop runs for 10 seconds */
for(i = 1; i < 50; i++) {
start = clock();
while( (end - start) / fps < 1) {
if(kbhit() != 0) {
keyhold = getch();
putch(keyhold);
}
end = clock();
}
putch(1);
}
return(0);
}
You might also want to #include <conio.c>
to get full conio.h funcionality.
Tom vC
conio.<b>c</b>
Yes, I know (now) HTML doesn't work here.
I only glanced at the red text as the bottom.