1
2string gen_random(int len) {
3 string s;
4 static const char alphanum[] =
5 "0123456789"
6 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
7 "abcdefghijklmnopqrstuvwxyz";
8
9 for (int i = 0; i < len; ++i) {
10 s+= alphanum[rand() % (sizeof(alphanum) - 1)];
11 }
12
13 return s;
14