account admin; ifstream ifile("D:\\admin.txt"); string id; string pas; if (getline(ifile>>ws, id)) { if (getline(ifile>>ws, pas)) { admin.id = id; admin.password = pas; } } ifile.close(); string tmi; cout << admin.id << endl; cout << "wrong" << endl; string tmp; system("cls"); cout << "ID:" << ends; cin >> tmi; if (tmi == admin.id) { cout << "Password:" << ends; cin >> tmp; if (tmp == admin.password) { cout << " ___________________________________________________________________________________" << endl; cout << "| |" << endl; cout << "| Welcom,admin. | " << endl; cout << "| |" << endl; cout << "|___________________________________________________________________________________|" << endl; system("cls"); } }这段代码里cout<<admin.id这条语句被忽略无法执行是为什么
时间: 2024-02-16 08:26:46 浏览: 138
FILE_COPY-and-RENAME.rar_site:www.pudn.com
根据代码,文件中的管理员账户信息已经被读入到了`admin`对象中,所以`cout << admin.id`语句应该能够输出管理员账户的ID。但是,在这段代码中,`cout << admin.id`语句和后面的`cout << "wrong" << endl`语句之间没有添加换行符,所以这两个语句的输出结果会连在一起,导致输出结果不易观察。可以将这两个语句分别改为`cout << admin.id << endl`和`cout << "wrong" << endl`,然后再次运行程序,看是否能够输出管理员账户的ID。
阅读全文