getpwnam.c

来自「apue第二版每一章节的c语言源码」· C语言 代码 · 共 19 行

C
19
字号
#include <sys/types.h>#include <pwd.h>#include <stddef.h>#include <string.h>struct passwd *getpwnam(const char *name){    struct passwd  *ptr;    setpwent();    while ( (ptr = getpwent()) != NULL) {        if (strcmp(name, ptr->pw_name) == 0)            break;		/* found a match */    }    endpwent();    return(ptr);	/* ptr is NULL if no match found */}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?