I need to write a program that will read
magnetic cards and display the card code
on the screen in binary format (1's and 0's).
The signal from the card reader is connected
to the parallel port and can be read in
from address 0x379.

This is program that I have written but I'm
not sure if it works or not. If it does not work
I will not have time to fix it so it must
work the first time. If something is wrong with
the program can someone please tell me.


#include <stdio.h>
#include <conio.h>

void main()
{
char cls,rcp,prevCls=0,prevRead=0;
int in;

do
{ in = inp(0x379);

cls = (in & 0x80);
rcp = (in & 0x20);

if (!rcp && cls && prevRead)
printf("%d",(in >> 4) & 1);
else
if (!cls && prevCls)
printf("\n\n");
prevRead = rcp;
prevCls = cls;

} while (!kbhit());
return 0;
}