C++(11):产生随机数_c++11 随机数_风静如云的博客-CSDN博客
介绍了如何生成随机数,可以基于随机数生成随机字符串:
#include <cstring>
#include <chrono>
#include <random>
#include <iostream>using namespace std;string getRandomStr(int strLen)
{const static char *str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_.-+";const static int len = strlen(str);static default_random_engine e(chrono::system_clock::now().time_since