通行证生成器:如何使每个密码使用新行
Pass Generator: How to make each password use a new line?
我编写了一个基本上生成密码的小型控制台应用程序。它询问用户他想要多少个密码以及每个密码应该有多少个字符。它将密码保存到文件中,旨在将每个密码放在不同的行上。目前,它要求用户输入字符长度/密码数量,但它将其全部放在一行上。
我该如何使每个密码都有自己的行?
string characters = "abcdefghi9182345$??=%(&)(%jklmnopqrstuv211935960473/=?$$=)&/$%=()wxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!$%&/()=";
int length;
int pwds;
int usrInpt;
int num;
(我知道我在上面的字符串中使用了一些字母/数字两次,但我这样做了,所以它更频繁地使用"$/(%(§"等字符(
cin >> usrInpt;
if (usrInpt == 1)
{
system("cls");
cout << "You chose to generate a password!" << endl;
cout << "How many passwords ?" << endl;
cin >> pwds;
cout << "How many characters ?" << endl;
cin >> length;
ofstream out_file;
out_file.open("Passwords.txt");
srand(time(0));
for (int i = 0; i < pwds; i++)
{
for (int j = 0; j < length; j++)
{
num = rand() % 70 + 1;
out_file << characters[num];
system("cls");
cout << "Passwords.txt created!" << endl;
}
}
正如我所说,预期是每个密码都打印在自己的行上。
在
第二个循环之后和结束第一个循环之前添加一个out_file << std::endl;
。
for (int i = 0; i < pwds; i++)
{
for (int j = 0; j < length; j++)
{
}
....
out_file << std::endl;
}
您还希望将"创建"消息移动到内部循环之外。
相关文章:
- 使用新行和不使用新行读取文件
- 遇到新行时,有没有办法停止istream_iterator
- PangoLayout 中忽略的新行
- 使用 clang 格式时,当行很大时,如何将右括号分成新行?
- 如何检测将文本文件读入 int 数组的新行
- 当 getline 直到新行才读取时会发生什么?
- 添加新行时工作代码引发异常.调试技巧?
- QTree查看新行,没有布局就不可见已更改
- 新行上的 clang 格式右括号
- C++流:保存到新行而不是覆盖旧行
- (C++) 使用诅咒打印从文件中读入的新行
- 按升序输出整数时,将最后一个整数放在新行上
- 用C++计算输入文本的新行数
- 为什么我的代码在终端中没有输出任何内容.开始新行没有错误
- WriteConsoleOutputCharacterW - 我的新行在哪里?
- 为什么当测试用例数为 1 时,我的程序不输入而是打印新行?
- 如何运行 while 循环直到到达新行?
- 从文本文件读取时,如何知道是否已到达新行?
- 句子转换器在存在新行的情况下不起作用
- 通行证生成器:如何使每个密码使用新行