OSA Practical : Group B: C/CPP Program to Display Logged in Users

#include<pwd.h>
#include<sys/types.h>
#include<unistd.h>
#include<stdio.h>
main()
{
struct passwd *procuid;
procuid=getpwuid(getuid());
printf("\n The Real User Name is %s ", procuid->pw_gecos);
printf("\n The Login Name is %s ", procuid ->pw_name);
printf("\n The Home Directory is %s", procuid ->pw_dir);
printf("\n The Login Shell is %s ", procuid ->pw_shell);

printf("\n The uid is %lu ", (unsigned long) getpwuid(getuid())->pw_uid);
printf("\n The gid is %lu \n\n", (unsigned long) getpwuid(getuid())->pw_gid);
}
SHARE
    Blogger Comment
    Facebook Comment