随手写的,生成几个GUID有用,大规模用就不好说了。
/* annidy@gmail.com */
const char* newGUID()
{
srand(time(NULL));
static char buf[64] = {0};
snprintf(buf, sizeof(buf) ,
"{%08X-%04X-%04X-%04X-%04X%04X%04X}" ,
rand()&0xffffffff,
rand()&0xffff,
rand()&0xffff,
rand()&0xffff,
rand()&0xffff, rand()&0xffff, rand()&0xffff
);
return (const char*)buf;
}