Write a C program that takes one or more file or directory names as command line input and reports the following information on the file. - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Thursday, October 6, 2011

Write a C program that takes one or more file or directory names as command line input and reports the following information on the file.


Write a C program that takes one or more file or directory names as command line input and reports the following information on the file.

                                                         1.         file type
                                                         2.         number of links
                                                         3.         read, write and execute permissions
                                                         4.         time of last access


PROGRAM

#include<stdio.h>
main()
{
FILE *stream;
int buffer_character;
stream=fopen(“test”,”r”);
if(stream==(FILE*)0)
{
fprintf(stderr,”Error opening file(printed to standard error)\n”);
fclose(stream);
exit(1);
}
}
if(fclose(stream))==EOF)
{
fprintf(stderr,”Error closing stream.(printed to standard error)\n);
exit(1);
}
return();
}

No comments:

Post a Comment