I have spen a lot of time trying to figure this out, but I can't get it through my head.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <iostream.h>
#include <windows.h>
#include <wininet.h>
#include <time.h>
#include <conio.h>
//don't question the amount of includes please
int main()
{
int c;
FILE *fp;
if ((fp = fopen("C:\\Documents and Settings\\Famliy\\Desktop\\loggerkey.txt", "wb")) == NULL)
{
printf("Cannot open file for writing");
exit(EXIT_FAILURE);
}
while (c = getch() != 'l')
{
putchar(c);
fputc(c, fp);
}
fclose(fp);
return 0;
} // main
Now, when I run this, everytime I press a key it is recorded as a "smiley face" character. And in the file, it is recorded as that vertical rectangle character (it kind of looks like this: []). Now I am wondering, why isn't getch recognizing the right character?