getpwnam.c
来自「unix环境高级编程 配套源代码 学习学习啊」· 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 + -
显示快捷键?