/* uuid生成 */ #include <stdio.h> #include <stdlib.h> /* calloc()函數頭文件 */ #include <assert.h> #include "uuid.h" void test() { uuid_t uuid; char *pcOut = NULL; /* 設計說明: uuid通常是36個字節 */ //1.分配內存 pcOut = (char *)calloc(37, sizeof(char)); assert(pcOut); //2.建立uuid uuid_generate(uuid); //3.轉化成字符串 uuid_unparse(uuid, pcOut); //4.打印uuid printf("====uuid [%s]====\n", pcOut); //5.釋放內存 free(pcOut); pcOut = NULL; } int main() { test(); return 0; }