#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
char *charStr;
int stringLength;
void genRandom() {
static const char alphanum[] =
"0123456789"
"!@#$%^&*"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
for (int i = 0; i < stringLength; ++i) {
charStr[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
}
charStr[stringLength] = 0;
}
int main()
{
while(true)
{
genRandom();
cout < charStr;
}
return 0;
}
问题出现在编译时。虽然编译没有错误,但是程序没有显示任何内容,然后就停止运行了。所以我的问题是,这段代码有什么问题?