#include <iostream> #include <uuid/uuid.h> #include <ctime> #include <string> #include <sstream> #include <unistd.h> #include <fstream> using namespace std; static char *uuidValue = (char *)malloc(40); static char *dtValue = (char *)malloc(20); char *getTimeNow() { time_t rawTime = time(NULL); struct tm tmInfo = *localtime(&rawTime); strftime(dtValue, 20, "%Y%m%d%H%M%S", &tmInfo); return dtValue; } char *getUuidValue1() { uuid_t newUUID; uuid_generate(newUUID); uuid_unparse(newUUID, uuidValue); return uuidValue; } void invokeFunc(void(*funcName)(int)); void printUuidValue8(int len); int main() { invokeFunc(printUuidValue8); return 0; } void printUuidValue8(int len) { for(int i=0;i<len;i++) { cout<<"I="<<i<<",value="<<getUuidValue1()<<",now is "<<getTimeNow()<<endl; sleep(1); } cout<<"Finished in printUuidValue8() and now is "<<getTimeNow()<<endl; free(dtValue); free(uuidValue); } void invokeFunc(void(*funcName)(int)) { int len=100; (*funcName)(len); }