![]() |
#2
yuccn2014-10-10 17:07
|

string GetRandomString()
{
const int SIZE_CHAR = 8; //生成32 + 1位C Style字符串
const char CCH[] = "0123456789abcdefghijklmnopqrstuvwxyz";
srand((unsigned)time(NULL));
char ch[SIZE_CHAR + 1] = {0};
for (int i = 0; i < SIZE_CHAR; ++i)
{
int x = rand() / (RAND_MAX / (sizeof(CCH) - 1));
ch[i] = CCH[x];
}
return ch;
}
{
const int SIZE_CHAR = 8; //生成32 + 1位C Style字符串
const char CCH[] = "0123456789abcdefghijklmnopqrstuvwxyz";
srand((unsigned)time(NULL));
char ch[SIZE_CHAR + 1] = {0};
for (int i = 0; i < SIZE_CHAR; ++i)
{
int x = rand() / (RAND_MAX / (sizeof(CCH) - 1));
ch[i] = CCH[x];
}
return ch;
}