Go to the first, previous, next, last section, table of contents.


getpwent

Syntax

#include <pwd.h>

struct passwd *getpwent(void);

Description

This function retrieves the next available password file entry. For MS-DOS, this is simulated by providing exactly one entry:

struct passwd {
  char * pw_name;    /* getlogin() */
  int    pw_uid;     /* getuid() */
  int    pw_gid;     /* getgid() */
  char * pw_dir;     /* "/" or getenv("HOME") */
  char * pw_shell;   /* "/bin/sh" or getenv("SHELL") */
};

Return Value

The next passwd entry, or NULL if there are no more.

Portability

not ANSI, not POSIX

Example

struct passwd *p;
setpwent();
while ((p = getpwent()) != NULL)
{
  printf("user %s name %s\n", p->pw_name, p->pw_gecos);
}
endpwent();


Go to the first, previous, next, last section, table of contents.