All about programming in GNU/LINUX

Program to print the size,i-node number and Owner Id in Gnu/Linux

#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<unistd.h>
#include<pwd.h>
int main()
{

    struct stat *info;

    int i;
    char *path;
    path=(char *)malloc(200);
    printf(“\nEnter the path of the file whose information is to be found: “);
    scanf(“%s”,path);
    i=stat(path,info);

    if(i==-1)
    {
        printf(“\nstat failed\n\n\n\n”);
        exit(0);
    }

    printf(“\nSize of the file:%d Bytes”,info->st_size);
    printf(“\nOwner Id of the file:%d “,info->st_uid);
    printf(“\nGroup Id of the file owner:%d “,info->st_gid);

    printf(“\nInode NO:%d\n\n\n\n “,info->st_ino);
    return 0;
}

Advertisements

2 responses

  1. please include mailing list on your blog ;receiving posts as digest , nice posts.

    May 27, 2012 at 8:01 am

    • Thank you very much Mohammed. Ya , i’ll include mailing lists option very soon on my blog .

      May 28, 2012 at 2:52 pm

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