Last active
August 26, 2018 19:37
-
-
Save Nazgolze/2be0c4264f01e780da82 to your computer and use it in GitHub Desktop.
turn input to hex
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() | |
{ | |
size_t bytes_read = 0; | |
char buf[1024] = {0}; | |
int idx; | |
do { | |
bytes_read = fread(buf, 1, sizeof(buf), stdin); | |
for(idx = 0; idx < bytes_read; idx++) | |
printf("0x%02hhx ", (unsigned char)buf[idx]); | |
} while (bytes_read == sizeof(buf)); | |
printf("\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment