int main() { int i; for (i=1;i<=1000000;i++) findAge(i); printf("Finish...\n"); getchar(); return 0; }
void getInfo() { struct passwd *pw; struct group *gr; struct stat st; struct hostent *ht; struct utsname un; char *user; char permissions[9]; char hostname[1024]; user = getenv("USER"); char lastChar = user[strlen(user) - 1]; pw = getpwnam(user); gr = getgrgid(pw->pw_gid); uname(&un); stat(pw->pw_dir, &st); gethostname(hostname, 1024); getPermissions(permissions, st.st_mode); printf("\nAbout Me\n"); printf("========\n\n"); printf("Unix User : %s (%d)\n", pw->pw_name, pw->pw_uid); printf("Name : %s\n", pw->pw_gecos); printf("Unix Group : %s (%d)\n", gr->gr_name, gr->gr_gid); printf("Unix Home : %s\n", pw->pw_dir); printf("Home Permission : %s\n", permissions); printf("Login Shell : %s\n", pw->pw_shell); findAge(); printf("\nOther users that end with '%c':\n ", lastChar); printOthers(lastChar, gr->gr_mem); printf("\nAbout My Machine\n"); printf("================\n\n"); printf("host : %s\n", hostname); printf("System : %s %s\n", un.sysname, un.release); }