Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Stat()

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

Comments

  • trk_naidutrk_naidu Member Posts: 4
    : 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
    #include
    #include
    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.



  • neilsheltonneilshelton Member Posts: 34
    Thanks for your help.

Sign In or Register to comment.