1
当控制台打开并且程序运行时,我只能看到一个闪烁的光标。 有什么我做错了吗?程序运行速度太快,我看不到它?cout字符串期间在控制台上闪烁光标
感谢您提前给予任何帮助。
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
string RandomString(int len)
{
srand(time(0));
string str = "01213456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
int pos;
while (str.size() != len) {
pos = ((rand() % (str.size() - 1)));
}
return str;
}
int main()
{
string random_str = RandomString(10);
cout << "random_str : " << random_str << endl;
system("pause");
return 0;
}
您的'RandomString'函数不会将任何字符添加到'str'。它永远不会回来。 –