20 lines
311 B
C
20 lines
311 B
C
#include <sys/types.h>
|
|
#include <unistd.h>
|
|
#include <pwd.h>
|
|
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
int main(void) {
|
|
struct passwd *pw = getpwuid(getuid());
|
|
if (!pw) {
|
|
fprintf(stderr, "whoami: %s\n", strerror(errno));
|
|
return 1;
|
|
}
|
|
|
|
puts(pw->pw_name);
|
|
return 0;
|
|
}
|