0
這裏是我的代碼:輸入查詢到文本文件
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int would;
string pass;
cout << "Password Manager v.1" << endl << endl;
cout << "What's the secret?" << endl;
cin >> pass;
if(pass == "youcantknowsorry"){
cout << "Access granted." << endl << endl;
cout << "Would you like to add a new password (1) or view your passwords? (2)" << endl;
cin >> would;
if(would == 1){
ofstream myfile;
myfile.open ("example.txt");
myfile << "NewPassword" << endl; <--- HOW CAN I MAKE THAT INPUT?
myfile.close();
}
if(would == 2){
cout << "Your passwords will open in a text file.";
}
}
return 0;
}
我想寫一個密碼管理自己。我使用類似cout
的方法成功創建,打開並寫入文件。但是,我需要用戶輸入信息並將其保存在文件中。
'想寫一個密碼管理器對於我自己「 - 請不要這樣做。嘗試使用現有的。 – devnull