UNIX环境高级编程学习之第六章系统数据文件和信息-取所有用户名和UID, GID
[code lang=”cpp”]#include <stdio.h>
#include <pwd.h>
#include <stddef.h>
int main()
{
struct passwd *ptr;
setpwent();
while((ptr = getpwent()) != NULL)
{
printf("name = %-10s ", ptr->pw_name);
printf("uid = %-6u ", ptr->pw_uid);
printf("gid = %-6u /n", ptr->pw_gid);
}
endpwent();
return 0;
}

[/code]

发表评论