StudyingUnixInterface/6/etc/group.c

26 lines
355 B
C
Raw Normal View History

2020-12-09 10:08:25 +00:00
#include <grp.h>
#include <stdio.h>
int main(void){
struct group *p_gp = getgrnam("sudo");
if(p_gp == NULL) {
printf("getgrgid error\n");
return -1;
}
printf("%d %s", p_gp->gr_gid, p_gp->gr_name);
char **p_men = p_gp->gr_mem;
while(*p_men != NULL){
printf(" %s", *p_men);
p_men++;
}
printf("\n");
return 0;
}