Mail Archives: djgpp/1997/11/14/18:16:00
ionicis AT geocities DOT com wrote:
>
> Ok, what EXACTLY does that interrupt function do? I need to know
> EXACTLY what it does when called. I'm very new to keyboard interrupts,
> so below is a little code snippet I wrote as a test program for the
> keyboard interrupt functions. I want the program to prompt the user via
> the first printf(), and then call get_key(), and when the user presses a
> key (because I assume that int6h/00h waits for the user to hit a key,
> then returns the data), and then it tells the user what key was hit.
> For some reason, the first printf() dosen't execute until the user hits
> a key. When a key is hit, both printf()s execute. Why is this? BTW,
> I'm using DJGPP.
>
> Code snippet removed
Interesting !
I believe that int 16h/00h does what you think it should
It wait for a key an then return with the ascii character in AL reg
(and scan code in AH reg)
Your problem if with printf .. well .. it is not realy a problem !
printf is line buffered
You simply need to add a "\n" at the END of the string .. or ..
add a call to fflush(stdio); after printf to send the buffer to the
screen !
that is why the first printf is called but does not show until the
second printf
if you ask why does the second printf show, there is no "\n" at the end
...
The second printf show when the program terminate and close stdout !
if you want a proof of this call _exit instead of return at the end of
the prog
and you will see !
note:
_exit() does not clean up while
exit() does !
- Raw text -