#include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> char* genRandomString(int length) { int flag, i; char* string; srand((unsigned) time(NULL )); if ((string = (char*) malloc(length)) == NULL ) { //myLog("Malloc failed!flag:14 "); return NULL ; } for (i = 0; i < length - 1; i++) { flag = rand() % 3; switch (flag) { case 0: string[i] = 'A' + rand() % 26; break; case 1: string[i] = 'a' + rand() % 26; break; case 2: string[i] = '0' + rand() % 10; break; default: string[i] = 'x'; break; } } string[length - 1] = '