apue 获取用户信息

来源:互联网 发布:mac无法搜索移动硬盘 编辑:程序博客网 时间:2024/06/04 15:41
#include<pwd.h>
#include<stddef.h>
#include<string.h>
#include<stdio.h>


struct passwd*
getwnam(const char *name)
{
struct passwd *ptr;
setpwent();
while((ptr = getpwent()) != NULL)
{
if(strcmp(name, ptr->pw_name) == 0)
break;
}
endpwent();
printf("%s\n", ptr->pw_name);
printf("%s\n", ptr->pw_passwd);
printf("%s\n", ptr->pw_gecos);
return (ptr);
}
void main()
{
getwnam("liu");
}
0 0
原创粉丝点击