Created
June 28, 2012 14:19
-
-
Save ebibibi/3011644 to your computer and use it in GitHub Desktop.
putxval
This file contains hidden or 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> | |
| /* 数値の16進表示 */ | |
| int putxval(unsigned long value, int column) | |
| { | |
| char buf[9]; | |
| char *p; | |
| p = buf + sizeof(buf) -1; | |
| *(p--) = '\0'; | |
| if(!value && !column) | |
| column++; | |
| while (value || column) { | |
| *(p--) = "0123456789abcdef"[value & 0xf]; | |
| value >>= 4; | |
| if (column) column--; | |
| } | |
| printf("%s\n", p+1); | |
| return 0; | |
| } | |
| int main(void) | |
| { | |
| putxval(0x10, 0); | |
| putxval(0xffff, 0); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment