#include <sys/types.h>
#include <pwd.h>
struct passwd *getpwent(void);
struct passwd {
char *pw_name; /* 用户名 */
char *pw_passwd; /* 用户密码 */
uid_t pw_uid; /* UID */
gid_t pw_gid; /* GID */
char *pw_gecos; /* 用户信息 */
char *pw_dir; /* 用户 home 目录 */
char *pw_shell; /* 使用的 shell 路径 */
};
#include <stdio.h>
#include <sys/types.h>
#include <pwd.h>
int main()
{
struct passwd *user;
while ((user = getpwent()))
printf ("%s:%d:%d:%s:%s:%s\n", user->pw_name, user->pw_uid,
user->pw_gid, user->pw_gecos, user->pw_dir, user->pw_shell);
endpwent();
return 0;
}
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |