#include <grp.h> struct group *getgrent(void);
This function returns the next available group entry. Note that for
MS-DOS, this is simulated. If the environment variable GROUP is set,
that is the name of the only group returned, else the only group is
"dos". Thus, under DOS, getgrent
will always fail on the
second and subsequent calls.
The return type of this and related function is as follows:
struct group { gid_t gr_gid; /* result of getgid() */ char ** gr_mem; /* gr_mem[0] points to getenv("USER"/"LOGNAME") or "user" */ char * gr_name; /* getenv("GROUP") or "dos" */ };
The next structure, or NULL
at the end of the list.
not ANSI, not POSIX
struct group *g; setgrent(); while ((g = getgrent()) != NULL) { printf("group %s gid %d\n", g->gr_name, g->gr_gid); } endgrent();
Go to the first, previous, next, last section, table of contents.