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