Created
October 10, 2018 00:33
-
-
Save mdippery/f6708a7497061453bfafd80882a6bbe9 to your computer and use it in GitHub Desktop.
Read one byte at a time and print the value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(int argc, char **argv) | |
{ | |
int i = 0; | |
int g = 0; | |
unsigned char ch; | |
if (argc > 1) { | |
g = atoi(argv[1]); | |
} | |
for (i = 0; i < g; i++) { | |
fread(&ch, 1, 1, stdin); | |
} | |
ch = 0; | |
fread(&ch, 1, 1, stdin); | |
printf("%#04x\n", ch); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment