whoami.c

来自「操作系统源代码」· C语言 代码 · 共 20 行

C
20
字号
/* whoami - print the current user name 	Author: Terrence W. Holm */#include <sys/types.h>#include <pwd.h>#include <stdlib.h>#include <unistd.h>#include <stdio.h>_PROTOTYPE(int main, (void));int main(){  struct passwd *pw_entry;  pw_entry = getpwuid(geteuid());  if (pw_entry == NULL) exit(1);  puts(pw_entry->pw_name);  return(0);}

⌨️ 快捷键说明

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