If you mean that you want the username and ID of the user who is running the program, you can use
Code:
#include <unistd.h>
#include <sys/types.h>
uid_t uid getuid(void);
You can pass this uid value to getpwdnam to return a structure representing the password file entry:
Code:
#include <pwd.h>
#include <sys/types.h>
struct passwd pw *getpwuid(uid);
And then read out the username with the pw_name field pointed to by pw.
You can also get the username of the current user (which may or may not be either the logged in user or the user running the process; see su -m) using
Code:
#include <stdlib.h>
char * uname = getenv("USER");
I hope that's legible,
— Robert J. Lee