Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

checking a file size i C

Posted on 2004-04-04
4
Medium Priority
?
245 Views
Last Modified: 2011-09-20
How could i check to see whether a file size > or ==  to some value?
(in C language)
0
Comment
Question by:achille67
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
Alf666 earned 80 total points
ID: 10753881
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
 

Author Comment

by:achille67
ID: 10753925
thanks  Alf666,
you gave me my first exciting answer through this website,
thanks again man.
Achille67.
0
 
LVL 9

Expert Comment

by:Alf666
ID: 10753949
Is this the reason why you offer so few points ? ;-)
0
 

Author Comment

by:achille67
ID: 10753966
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question