Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <string.h>
- #include <limits.h>
- int
- main(int argc, char* argv[])
- {
- while (1)
- {
- unsigned char s[CHAR_BIT];
- memset(s, 0, sizeof(s));
- int it = 0;
- while (it < CHAR_BIT) {
- unsigned char curr;
- if (scanf("%hhx", &curr) == 1) {
- for (int i = 0; i < CHAR_BIT; ++i) {
- s[i] = curr & (1 << i) ? s[i] | (1 << it) : s[i];
- }
- } else {
- return 0;
- }
- ++it;
- }
- for (int i = 0; i < CHAR_BIT; ++i) {
- printf("%hhx ", s[i]);
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment