1: #include <stdio.h> 2: #include <pwd.h> 3: #include <grp.h> 4: struct passwd *getpwuid(); 5: struct group *getgrgid(); 6: 7: main() 8: { 9: struct passwd *pp; 10: struct group *gn; 11: int uid, gid; 12: 13: pp=getpwuid(uid = getuid()); 14: gn=getgrgid(gid = getgid()); 15: 16: if (pp == NULL) 17: printf("%d", uid); 18: else 19: printf("%s", pp->pw_name); 20: 21: if (gn == NULL) 22: printf(".%d\n", gid); 23: else 24: printf(".%s\n", gn->gr_name); 25: 26: }