LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-07-2007, 11:05 AM   #1
kalamaraki
LQ Newbie
 
Registered: Oct 2006
Location: Athens - Greece
Distribution: Ubuntu 6.06 LTS - the Dapper Drake
Posts: 13

Rep: Reputation: 0
Function that returns the size of a file in bytes in C


Hello everybody!

Does anyone know if there is a function in C that returns the size of a file in bytes? Is this function included in stdlib? I want to write programs that read and write in files and if they are asked to write/read in a space outside the file range, that request should be rejected.

Thanks in advance.
 
Old 01-07-2007, 11:11 AM   #2
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
man 2 stat
It is in libc.
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
The stat() and fstat() calls conform to SVr4, SVID, POSIX, X/OPEN, 4.3BSD. The lstat() call conforms to 4.3BSD and SVr4.
 
Old 01-07-2007, 11:22 AM   #3
kalamaraki
LQ Newbie
 
Registered: Oct 2006
Location: Athens - Greece
Distribution: Ubuntu 6.06 LTS - the Dapper Drake
Posts: 13

Original Poster
Rep: Reputation: 0
Smile

Thanks for the quick reply
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
kernel drops packets of size less than 48 bytes neelay1 Linux - Networking 1 07-16-2006 02:56 AM
Bash script that returns the size of a file spank Linux - General 6 01-19-2006 03:24 PM
C function that returns $HOME cbranje Programming 1 02-12-2005 05:41 PM
calling sys_read inside sys_write returns number of bytes read as zero appas Linux - Software 0 08-28-2004 07:21 AM
open function returns error sudheernair Programming 2 05-07-2004 11:14 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration