可以使用getuid()获取用户的ID号,然后通过getpwuid函数通过用户的uid查找用户的passwd数据来获取系统登录的用户名。include <stdio.h>#include <pwd.h>#include <unistd.h>int main(void){struct passwd *pwd;pwd = getpwuid(getuid());printf("当前登陆的用户名为:%s\n", pwd->pw_name);return...