Created
January 27, 2015 09:18
-
-
Save draganglumac/4dfeb8c0f57c5fa08d73 to your computer and use it in GitHub Desktop.
GUID to string (decimal and hex)
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 <stdlib.h> | |
| #include <string.h> | |
| #include <stdio.h> | |
| int main() { | |
| uint8_t guid[16] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; | |
| size_t size = sizeof guid; | |
| char dbuffy[49] = {}; | |
| for (int j = 0; j < size; j++) { | |
| char curr[4]; | |
| sprintf(curr, "%03u", guid[j]); | |
| strncat(dbuffy, curr, 4); | |
| } | |
| printf("GUID in Decimal: %s\n", dbuffy); | |
| char hbuffy[33] = {}; | |
| for (int i = 0; i < size; i++) { | |
| char temp[3]; | |
| sprintf(temp, "%02x", guid[i]); | |
| strncat(hbuffy, temp, 3); | |
| } | |
| printf("GUID in Hex: %s\n", hbuffy); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment