004
09.06.2004, 19:03 Uhr
Pablo
Supertux (Operator)
|
C++: |
#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <pwd.h> #include <string.h>
void user_info(const char* user) { struct passwd* pass=NULL; pass = getpwnam(user); if (!pass) { printf("The user '%s' is unknown\n",user); return; } printf("User Name: %s\nuid=%d\ngid=%d\nreal name=%s\nhome dir:%s\nshell: %s\n", pass->pw_name, pass->pw_uid, pass->pw_gid, pass->pw_gecos, pass->pw_dir, pass->pw_shell); }
int main(int argc, char** argv) { int i; char user[20]; for(i=1; i<argc; ++i) { strcpy(user, argv[i]); if (argc==1) strcpy(user,getenv("HOME")); printf("Printing user information for '%s'\n", user); user_info(user); } return 0; }
|
So funktioniert es bei mir -- A! Elbereth Gilthoniel! silivren penna míriel o menel aglar elenath, Gilthoniel, A! Elbereth! Dieser Post wurde am 09.06.2004 um 19:03 Uhr von Pablo editiert. |