/* Display information about any file */
#include <time.h>
#include <sys\stat.h>
#include <stdio.h>
void main() {
    char fname[20];
    printf("Enter the name of the file to read: ");
    scanf("%s", fname);
    struct stat status;
    FILE *fp;
    fp=fopen(fname, "r");
    fstat(fileno(fp), &status);
    printf("Size of file : %d bytes\n\n", status.st_size);
    if (status.st_mode & S_IREAD)
         printf("You have permission to read this file.\n\n");
    if (status.st_mode & S_IWRITE)
         printf("You have permission to write to this file.\n\n");
    printf("Last date of modification : %s",ctime(&status.st_ctime));
    getch();
    return 0;
}
Tuesday, February 10, 2015
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment