cuserid() - return user ID (login name) as a string
#include <stdio.h>
char * cuserid (char *s)
The cuserid(3) function returns the login name of the real or effective owner of the process.
If s is NULL, then the function returns a pointer to a static buffer, which may be overwritten by subsequent calls to cuserid(3).
If s is not NULL, it's assumed to be a buffer that is at least {L_cuserid} bytes long; {L_cuserid} is defined in <stdio.h>.
If s is not NULL, cuserid(3) returns s; if s is NULL, cuserid(3) returns a pointer to an internal buffer.
If the login name was found, it will be in the appropriate buffer. If the login name could not be found, the buffer contains a null byte `\0'.
getlogin(2)
getpwnam(2)
getpwuid(2)
getuid(2)
geteuid(2)