日期:2014-05-16 浏览次数:21015 次
#include <stdio.h> #include <uuid/uuid.h> int save2cache(char* keys) { /*生成uuid*/ uuid_t uu; uuid_generate(uu); memset(keys, 0x00, sizeof(keys)); sprintf(keys, "%x", uu); return 0; } int save2cache2(char* keys) { /*生成uuid*/ uuid_t uu; uuid_generate_random(uu); memset(keys, 0x00, sizeof(keys)); sprintf(keys, "%x", uu); return 0; } int save2cache3(char* keys) { /*生成uuid*/ uuid_t uu; uuid_generate_time(uu); memset(keys, 0x00, sizeof(keys)); sprintf(keys, "%x", uu); return 0; } int main(int argc, char** argv) { char keys[50], keys2[50], keys3[50]; save2cache(keys); printf("keys=%s\n", keys); save2cache(keys); printf("keys=%s\n", keys); printf("/////////////////\n"); save2cache(keys2); printf("keys2=%s\n", keys2); save2cache(keys3); printf("keys3=%s\n", keys3); return 0; }