Keylogger output file

Currently mucking around with a keylogger. Looking at a few examples, I was just wondering, but why does this keylogger print the keystroke as a string here:

 
fprintf(OUTPUT_FILE, "%s", &key_stroke);


instead of:

 
fprintf(OUTPUT_FILE, "%c", key_stroke);


You can check out the repo I'm using here: https://github.com/GiacomoLaw/Keylogger/tree/master/windows

Thank you!
why does this keylogger print the keystroke as a string here:

What do you mean?

1
2
3
4
int n{ 65 };

printf( "%s\n", &n );
printf( "%c\n", n );


A
A
key_stroke is an int but is treated as a string. The programmer is an optimist and expects that the value and the terminating 0 is at the right position to form a valid string.
Topic archived. No new replies allowed.