新闻资讯
看你所看,想你所想

setpwent()

setpwent()

setpwent()用来将getpwent()的读写地址指回密码档案开头。

基本介绍

  • 外文名:setpwent()
  • 头档案:#include<pwd.h>
  • 原型:void setpwent(void);
  • 说明:指回密码档案开头

头档案

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

函式原型

void setpwent(void);

範例

#include<pwd.h>
#include<sys/types.h>
main()
{
struct passwd *user;
int i;
for(i=0;i<4;i++){
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);
}
setpwent();
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();
}
执行 root:0:0:root:/root:/bin/bash
bin:1:1:bin:/bin
daemon:2:2:daemon:/sbin
adm:3:4:adm:/var/adm
root:0:0:root:/root:/bin/bash

转载请注明出处海之美文 » setpwent()

相关推荐

    声明:此文信息来源于网络,登载此文只为提供信息参考,并不用于任何商业目的。如有侵权,请及时联系我们:ailianmeng11@163.com