C/C++ on Linux/Unix

Moderators: Lundin
Number of threads: 314
Number of posts: 633

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Stat() Posted by neilshelton on 13 Jan 2004 at 5:31 AM
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
Report
Re: Stat() Posted by trk_naidu on 13 Jan 2004 at 8:28 PM
: 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.



Report
Re: Stat() Posted by neilshelton on 24 Jan 2004 at 4:54 PM
Thanks for your help.




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.