Hello. There is a task: "There are several users registered in the computer system. Develop a program that a user can determine whether they can access reading (r), write (w), or execute files (x) based on the user account name." I have a ready login and password verification code. But the problem is that it is only suitable for one login. How to put more logins here, and how to make different messages for different users?
#include <iostream> #include <string> using namespace std; int main() { string login = "Alice"; string password = "Bobly"; string log1; string pass; for (int i=0; i<3; i++) { cout << i+1 << "Enter login:"; cin >> log1; if (log1 == login) { cout << "Login accepted, enter password:" << endl; cin >> pass; if (pass == password) { cout << "Welcome!"; return 0; } else cout << "Access denied!"; return 0; } } }
sudo -u <username> [ -x <filename> ] ; echo $?sudo -u <username> [ -x <filename> ] ; echo $?? - jfs