



(14 votes)/* * Example program by pipas@linux.pte.hu * This program lists all the users from * the user database (/etc/passwd). * * http://www.metalshell.com/ */ #include <stdio.h> #include <pwd.h> #include <sys/types.h> main() { struct passwd *user; /* open the user database */ setpwent(); /* read the user data one by one and print their names to stdout */ while( (user=getpwent())!=NULL ) printf("%s\n", user->pw_name); /* close the database */ endpwent(); } /*main*/