//install libuuid-devel
sudo yum install libuuid libuuid-devel
#include <iostream> #include <stdio.h> #include <uuid/uuid.h> char *uuid_value=(char*)malloc(40); char * get_uuid() { uuid_t new_uuid; uuid_generate(new_uuid); //uuid_generate_time_safe(new_uuid); //char *uuid_value=(char*)malloc(40); //uuid_unparse_lower(new_uuid,uuid_value); //uuid_parse(uuid_value,new_uuid); uuid_unparse(new_uuid,uuid_value); return uuid_value; } void print_uuid(const int&len) { for(int i=0;i<len;i++) { std::cout<<i+1<<","<<get_uuid()<<std::endl; } } int main(int args,char** argv) { print_uuid(atoi(argv[1])); free(uuid_value); std::cout<<"Finished in "<<__FUNCTION__<<std::endl; }
Compile
g++ -std=c++0x -I. *.cpp -o h1 -luuid;
Run
./h1 100;
标签:char,uuid,centos,libuuid,value,devel,luuid,new From: https://www.cnblogs.com/Fred1987/p/17610929.html