C program to print userid and group id
#include <stdio.h>
#include <sys/types.h>
#include <pwd.h>
#include <unistd.h>
#include <sys/types.h>
#include <grp.h>
int main()
{
struct passwd
*pwd;
struct
group *grp;
int uid, gid;
pwd =
getpwnam("nobody");
if (pwd == NULL)
{
printf("Failed to get uid");
}
uid =
pwd->pw_uid;
grp =
getgrnam("root");
if (grp == NULL)
{
printf("Failed to get gid");
}
gid =
grp->gr_gid;
printf("\n
%d %d \n", uid, gid);
return 0;
}
~