zoukankan      html  css  js  c++  java
  • getpwuid()

    getpwuid函数是通过用户的uid查找用户的passwd数据。如果出错时,它们都返回一个空指针并设置errno的值,用户可以根据perror函数查看出错的信息。

    外文名
    getpwuid()
    头文件
    #include <sys/types.h>
    原    型
    struct  passwd *getpwuid
    函数说明
    查找用户的passwd数据

    头文件

    编辑
    1
    2
    #include <sys/types.h>
    #include <pwd.h>

    函数原型

    编辑
    1
    struct passwd *getpwuid(uid_t uid);

    函数说明

    编辑
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    The passwd structure is defined in <pwd.h> as follows:
    struct passwd {
    char *pw_name; /*user name */
    char *pw_passwd; /*user password */
    uid_t pw_uid; /*user id */
    gid_t pw_gid; /*group id */
    char *pw_gecos; /*user real name */
    char *pw_dir; /*home directory */
    char *pw_shell; /*shell program */
    };

    范例

    编辑
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    #include <pwd.h>
    #include <sys/types.h>
    #include <stdio.h>
    intmain()
    {
    uid_t my_uid;
    //my_uid =500;
    struct passwd *my_info;
    my_info =getpwuid( getuid() );
    //my_info = getpwnam( "fflg" );
    printf"my name = [%s] ", my_info->pw_name );
    printf"my passwd = [%s] ", my_info->pw_passwd );
    printf"my uid = [%d] ", my_info->pw_uid );
    printf"my gid = [%d] ", my_info->pw_gid );
    printf"my gecos = [%s] ", my_info->pw_gecos );
    printf"my dir = [%s] ", my_info->pw_dir );
    printf"my shell = [%s] ", my_info->pw_shell );
    return0;
    }
  • 相关阅读:
    Python strip()方法介绍
    python实现猜拳游戏
    Shopping cart program--python
    转置矩阵的行和列
    Oldman python of full stack-Day2
    根据输入生成二维码
    python 中设置字体/背景颜色
    如何用Notepad++运行python程序
    web前端【第十篇】jQuery基本语法
    web前端【第九篇】JS的DOM对象三
  • 原文地址:https://www.cnblogs.com/DawaTech/p/6805234.html
Copyright © 2011-2022 走看看