linux C++生成uuid

sudo apt-get install uuid-dev

安装生成uuid的库

#include <iostream>;
#include <stdio.h>;
#include <uuid/uuid.h>;

int main()
{
        uuid_t uu;
        uuid_generate( uu );
        std::cout << uu << std::endl;
        int i;
        for(i=0;i<16;i++)
        {
            printf("%x  ",uu);
        }
        printf("\n");
        return 0;
}

编译的时候需要将对应的库添加上:

#g++ -o –luuid uuid uuid.o

猜你喜欢

转载自www.cnblogs.com/rainsoul/p/9077724.html