: Please can someone tell me how to use the stat() function as i can't figure it out.
: Eg, how to get the size of the file.
: Thanks
:
stat function is used to get the file attributes of a file .
here is a short program to use the stat function
#include<stdio.h>
#include<stdlib.h>
#include<sys/stat.h>
int main(int argc ,char **argv ){
struct stat buf;
stat("filename", &buf);
printf("length of the file %d",buf.st_size);
}/* end main */
see stat(3) for further details about stat and its fields.