随机字符串

随机字符串函数

ExpandedBlockStart.gif 代码
 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  }

 

 

 

转载于:https://www.cnblogs.com/pbreak/archive/2011/01/28/1947001.html

你可能感兴趣的:(随机字符串)