Saturday, June 19, 2010

Write a c program to find out the size and drive where file has stored of any given file?

#include "time.h"

#include "sys\stat.h"

#include "stdio.h"

int main(){

struct stat status;

FILE *fp;

fp=fopen("test.txt","r");

fstat(fileno(fp),&status);



printf("Size of file : %d",status.st_size);

printf("Drive name : %c",65+status.st_dev);

return 0;

}



Explanation:


Function int fstat (char *, struct stat *) store the information of open file in

No comments:

Post a Comment