⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getname.c

📁 基于网络编程的例子
💻 C
字号:
/* * getname.c - Get login names */#include <stdio.h>#include <stdlib.h>#include <sys/types.h>#include <unistd.h>#include <pwd.h>int main(void){	char *login;	struct passwd *pentry;		/* Get the login name */	if((login = getlogin()) == NULL) { /* oops */	perror("getlogin");	exit(EXIT_FAILURE);	}		/* Get the password entry for login */	if((pentry = getpwnam(login)) == NULL) {	perror("getpwnam");	exit(EXIT_FAILURE);	}	/* Display the password entry */	printf("user name: %s\n", pentry->pw_name);	printf("UID	     : %d\n", pentry->pw_uid);	printf("GID	     : %d\n", pentry->pw_gid);   	printf("gecos    : %s\n", pentry->pw_gecos);   	printf("home dir : %s\n", pentry->pw_dir);   	printf("shell    : %s\n", pentry->pw_shell);	exit(EXIT_SUCCESS);}

⌨️ 快捷键说明

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