All about programming in GNU/LINUX

Program to print the user ID and Username in GNU/LINUX using getuid and getlogin system calls

/* hackintosh rao \m/ , codes for GNU/LINUX
   program to print the user ID and username
  System calls used:1) uid_t getuid(void);
                    2) char *getlogin(void); */
#include<stdlib.h>Image
#include<unistd.h>
#include<sys/types.h>
int main()
{
    uid_t uid;/*uid_t is a build in data type, which can hold small numbers*/
    char* username;
    uid=getuid();
    username=getlogin();
    printf(“\nUID is:%d\nUsername:%s\n\n\n “,uid,username);
    return 0;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s