Skip to content

Instantly share code, notes, and snippets.

@oldpatricka
Created September 21, 2010 21:53
Show Gist options
  • Save oldpatricka/590653 to your computer and use it in GitHub Desktop.
Save oldpatricka/590653 to your computer and use it in GitHub Desktop.
Bandersnatch:~ patricka$ cat uuidtest.c
#import <uuid/uuid.h>
#import <stdio.h>
int main() {
uuid_t my_uuid;
uuid_generate(my_uuid);
char uuid_string[60];
uuid_unparse(my_uuid, uuid_string);
puts(uuid_string);
return 0;
}
Bandersnatch:~ patricka$ gcc uuidtest.c -o uuidtest
Bandersnatch:~ patricka$ ./uuidtest
F840130F-1E6B-4977-AFAD-7A2FC3CDFABF
Copy link

ghost commented Aug 19, 2015

- char uuid_string[60];
+ char uuid_string[37];
// e.g 128-bit uuid -> 16 bytes (hex -> * 2) + 4 hyphens + null_terminated = 37
// 16 * 2 + 4 + 1 = 37

8-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment