Skip to content

Instantly share code, notes, and snippets.

@Nazgolze
Last active August 26, 2018 19:37
Show Gist options
  • Save Nazgolze/2be0c4264f01e780da82 to your computer and use it in GitHub Desktop.
Save Nazgolze/2be0c4264f01e780da82 to your computer and use it in GitHub Desktop.
turn input to hex
#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