Question:Write a c program to know given file is regular file, character special or it is directory? 

Answer 
#include "time.h"
#include "sys\stat.h"
#include "stdio.h"
void main(){
    struct stat status;
    FILE *fp;
    stat("c:\\tc\\bin",&status);
    clrscr();
    if (status.st_mode & S_IFDIR)
         printf("It is directory.\n");
    if (status.st_mode & S_IFCHR)
         printf("It is chracter file.");
    if (status.st_mode & S_IFREG)
         printf("It is reggular file.");
    getch();
}
Output: It is directory. 

+ ExplanationNot Moderated
+ Report
Total Preview: 567
Write a c program to know given file is regular file, character special or it is directory?
Copyright © 2024. Powered by Intellect Software Ltd