Tuesday, May 22, 2018

Program to print details including Owner Access Permissions and File Access Time

/* Program to print details including owner access permissions, file access time, where file name is given as a command line argument.
*/

#include<stdio.h>

#include<sys/stat.h>


int main(int argc, char *argv[3])

{

int i,statchmod;
struct stat buffer;

printf("Give file name:\n");

for(i=1;i<argc;i++)

{
 
printf("file=%s:-\n",argv[1]);
   
if(stat(argv[i], &buffer)<0)
   
printf("Error in file stated");
else
   
statchmod=buffer.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
   
printf("Access permission(in octal): %o\n",statchmod);
   
        printf("Owenered=%d,gid=%d\n",buffer.st_uid,buffer.st_gid);
   
printf("Access time=%d\n", (time(&(buffer.st_atime))));

}
}




OUTPUT SCREEN:


No comments:

Post a Comment

Project on Library Management System (C++)

=> The project titled Library Management system is Library management software for monitoring and controlling the transactions in a lib...