setpwet()函数

setpwent()函数

功       能:是从头读取密码文件中的账号数据

相关函数:getpwent,endpwent

表头文件:#include <pwd.h>

                 #include <sys/types.h>

定义函数:void setpwent(void);

函数说明:setpwent()用来将getpwent()的读写地址指会密码文件开头。

返  回 值:无

 

/*********************************************************************************
 *      Copyright:  (C) 2013 fulinux<[email protected]>
 *                  All rights reserved.
 *
 *       Filename:  getpwent.c
 *    Description:  This file
 *                
 *        Version:  1.0.0(04/17/2013~)
 *         Author:  fulinux <[email protected]>
 *      ChangeLog:  1, Release initial version on "04/17/2013 01:42:35 PM"
 *                
 ********************************************************************************/
#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);
    }
    getpwent();
    user = getpwent();
    printf("%s :%d :%d :%s:%s:%s\n",user->pw_name, user->pw_uid, user->pw_gecos, user->pw_dir, user-
>pw_shell);
    endpwent();
}

 

 

你可能感兴趣的:(函数,setpwet)