티스토리 뷰

#include <stdio.h>
#include <sys/types.h>
#include <pwd.h>


int main()
{
	FILE* fp = fopen("/etc/passwd", "r");
	struct passwd *pw;

	while((pw = fgetpwent(fp)) != NULL) {
		printf("%s:%s:%d:%d:%s:%s:%s\n", pw->pw_name, pw->pw_passwd, pw->pw_uid, pw->pw_gid, pw->pw_gecos, pw->pw_dir, pw->pw_shell);
	}
	
	fclose(fp);
	return 0;

}
반응형

댓글