Created
June 30, 2011 02:56
-
-
Save kcbanner/1055532 to your computer and use it in GitHub Desktop.
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> | |
#include <limits.h> | |
char* i_to_hex_a(int value, char* str) { | |
//convert a 32 bit value to hex counterpart | |
//assumes str is 9 characters long | |
int i; | |
int a; | |
for(i = 0; i < 8; i++){ | |
a = (value && 0xF0000000); | |
if(a < 10){ | |
str[i] = '0' + a; | |
} else { | |
str[i] = '0' + 7 + a; | |
} | |
value = value << 4; | |
} | |
str[9] = 0; | |
} | |
int main() { | |
char str[9]; | |
int i; | |
for (i = 0; i < 0xffffffff; i++) { | |
i_to_hex_a(i, str); | |
printf("%x: 0x%s\n", i, str); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
include <stdio.h>
include <limits.h>
char* i_to_hex_a(int value, char* str) {
//convert a 32 bit value to hex counterpart
//assumes str is 9 characters long
}
int main() {
char str[9];
int i;
}