Sword 第三方库介绍二

懵懂的女人 提交于 2019-12-01 07:03:54
/* 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;
}

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!