|
|
| Linux Programmer's Reference (ISBN: 0072123559) |
 |
List Price: $19.99
Our Price: $19.99
Used Price: $3.87
Release Date: 10 December, 1999
Manufacturer: McGraw-Hill Osborne Media (Paperback)
Sales Rank: 165,538
Author: Richard Petersen
|
More Info
|
|
|
List Users
|
2003-05-01 22:05:53
|
| |
c
|
|
|
|
|
Category: source:c:linux
|
|
Description: Simple program to print all of the known users from the /etc/passwd file.
|
|
Platform: unix
|
|
Author: pipas
|
|
Viewed: 2810
|
|
Rating: 3.8/5 (12 votes)
|
|
|
| If you have any questions about
this piece of code or still need help, try posting your question on the forum. |
/*
* 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*/
|
|
|