getuid() gets identifier not username. To get the username, you have to additionally use getpwuid() :
struct passwd *passwd; passwd = getpwuid ( getuid()); printf("The Login Name is %s ", passwd->pw_name);
Look it up
And to get the host name you can use the gethostname() function.
source share