Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 248
  • Last Modified:

checking a file size i C

How could i check to see whether a file size > or ==  to some value?
(in C language)
0
achille67
Asked:
achille67
  • 2
  • 2
1 Solution
 
Alf666Commented:
Just use the stat() or the fstat calls.

Example :

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

main(int argc, char **argv) {
struct stat buf ;
int size = 100 ; // octets

  stat("file_name", &buf);
  if (buf.off_t >= size) {
     // do what you have to do
  }
}

man 2 stat will give you more infos.
0
 
achille67Author Commented:
thanks  Alf666,
you gave me my first exciting answer through this website,
thanks again man.
Achille67.
0
 
Alf666Commented:
Is this the reason why you offer so few points ? ;-)
0
 
achille67Author Commented:
My bad dude, next time u will have a bigger one :-)
Also i thought modulo will answer this question so i gave a little point only :-)
for not answering my previous questions as i wanted :-)

Achille67
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now