我需要使用 C++11 生成随机字符串的帮助。
我不知道如何继续,如果你能帮助我。
#include <random>
char * random_string()
{
static const char alphabet[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
static const MAX_LEN = 32; //MAX LENGTH OF THE NEW CHAR RETURNED
int stringLength = sizeof(alphabet)/sizeof(alphabet[0]);
for (int i = 0; i<=MAX_LEN;i++)
{
//now i don't know what i need to do help!
}
static const char test[MAX_LEN];
return test;
}
Run Code Online (Sandbox Code Playgroud)