随机字符串函数
代码
1 char* GetRandString(char vCode[],int number)
2 {
3 char* pvCode = vCode;
4 strcpy(vCode,"");
5 char verificationValue[64] = "00123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
6 char singleCode[2];
7 memset(singleCode,0,2);
8 srand((unsigned int)time((time_t *)NULL));
9 for(int i=1; i <= number; ++i)
10 {
11 sprintf(singleCode,"%c",verificationValue[(rand()%62)+1]);
12 strcat(vCode,singleCode);
13 }
14 return pvCode;
15 }
2 {
3 char* pvCode = vCode;
4 strcpy(vCode,"");
5 char verificationValue[64] = "00123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
6 char singleCode[2];
7 memset(singleCode,0,2);
8 srand((unsigned int)time((time_t *)NULL));
9 for(int i=1; i <= number; ++i)
10 {
11 sprintf(singleCode,"%c",verificationValue[(rand()%62)+1]);
12 strcat(vCode,singleCode);
13 }
14 return pvCode;
15 }