#include // getpw* #include // getpw* #include // getuid #include // perror #include using namespace std; void PrintUser(passwd * user) { cout << "\tname is " << user->pw_name << endl ; cout << "\tpassword is " << user->pw_passwd << endl; cout << "\tuid is " << user->pw_uid << endl; cout << "\tgid is " << user->pw_gid << endl; cout << "\tgecos is " << user->pw_gecos << endl; cout << "\thome is " << user->pw_dir << endl; cout << "\tshell is " << user->pw_shell << endl; cout << endl; } int main(int argc, char * argv[]) { passwd * entry; int count = 0; while (NULL != (entry = getpwent())) { PrintUser(entry); count ++; } cout << "There are a total of " << count << " password file entries." << endl; endpwent(); return 0; }