473,408 Members | 1,951 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Usoing fopen etc is there a way to find file size

Hello

I want to open the entire contents of a binary file (the files are quite
small) into memory. How can I find out the file size in bytes of the file I
am opening?

Angus Comber
an***@NOSPAMiteloffice.com

Nov 14 '05 #1
6 19001
Angus Comber wrote:
Hello

I want to open the entire contents of a binary file (the files are quite
small) into memory. How can I find out the file size in bytes of the file
I am opening?


See FAQs 12.40 and 19.12.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 14 '05 #2
Angus Comber wrote:

Hello

I want to open the entire contents of a binary file (the files are quite
small) into memory. How can I find out the file size in bytes of the file I
am opening?


This is Question 19.12 in the comp.lang.c Frequently
Asked Questions (FAQ) list

http://www.eskimo.com/~scs/C-faq/top.html

--
Er*********@sun.com
Nov 14 '05 #3
Angus Comber wrote:

Hello

I want to open the entire contents of a binary file (the files are quite
small) into memory. How can I find out the file size in bytes of the file I
am opening?

http://www.eskimo.com/~scs/C-faq/q19.12.html

Brian Rodenborn
Nov 14 '05 #4
"Richard Heathfield" <do******@address.co.uk.invalid> wrote in message
news:c0**********@hercules.btinternet.com...
Angus Comber wrote:
Hello

I want to open the entire contents of a binary file (the files are quite
small) into memory. How can I find out the file size in bytes of the file I am opening?


See FAQs 12.40 and 19.12.


I don't see a 12.40. Did you mean 12.38 (the highest number
I see under section 12) ?

Do I have the current link? http://www.eskimo.com/~scs/C-faq/top.html

-Mike
Nov 14 '05 #5
Mike Wahler wrote:
"Richard Heathfield" <do******@address.co.uk.invalid> wrote in message
news:c0**********@hercules.btinternet.com...
Angus Comber wrote:
> Hello
>
> I want to open the entire contents of a binary file (the files are
> quite
> small) into memory. How can I find out the file size in bytes of the file > I am opening?


See FAQs 12.40 and 19.12.


I don't see a 12.40. Did you mean 12.38 (the highest number
I see under section 12) ?


No, I meant 12.40 but it's my fault for not checking the online version. The
book has a 12.40, but some of the book answers aren't present in the online
version.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 14 '05 #6

"Richard Heathfield" <do******@address.co.uk.invalid> wrote in message
news:c0**********@hercules.btinternet.com...
Mike Wahler wrote:
"Richard Heathfield" <do******@address.co.uk.invalid> wrote in message
news:c0**********@hercules.btinternet.com...
Angus Comber wrote:

> Hello
>
> I want to open the entire contents of a binary file (the files are
> quite
> small) into memory. How can I find out the file size in bytes of the file
> I am opening?

See FAQs 12.40 and 19.12.


I don't see a 12.40. Did you mean 12.38 (the highest number
I see under section 12) ?


No, I meant 12.40 but it's my fault for not checking the online version.

The book has a 12.40, but some of the book answers aren't present in the online version.


Ah, OK thanks, hadn't thought of that. I have the hardcopy of the
C++ FAQs but not the C one. I suppose I'll put that on my list for
next visit to the bookstore. :-)

-Mike
Nov 14 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: typingcat | last post by:
Is it possible to read another web page in PHP? If is ASP.NET, the code would be ------------ WebRequest req=WebRequest.Create("http://www.microsoft.com"); WebResponse res=req.GetResponse();...
14
by: Aaron Couts | last post by:
I have a program that writes to a log file. It's compiled on RH Linux 7.3 (Kernel 2.4.18-18.7). It's using fopen in append mode. When the file reaches 51200000 bytes in size, the program will no...
7
by: git_cs | last post by:
Hey, guys and gals Somedays ago, I had asked for the DES algorithm in C language. Although I have written the algorthim in C myself, I am facing a peculiar problem, which I hope some of u guys and...
3
by: Patrice | last post by:
Hi, I would to call fopen function several time in my application. This application permits to read files which path is registered in a configuration file. For exemple: File 1 = toto.txt File 2...
15
by: uremae | last post by:
I tried to open some large files in my computer. (ram 512MB) 1. is there limitation of file size FOPEN? 2. if I have a file that is larger than the maximum size, how can I open the file?
20
by: David Mathog | last post by:
A program of mine writes to a tape unit. Output can be either through stdout or through a file opened with fopen(). When all the data is transferred to tape the program needs to close the output...
25
by: subramanian100in | last post by:
Consider the following program: #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv) { if (argc != 2) { printf("Usage: <program-name<text-file>\n");
3
by: siyaverma | last post by:
i am trying to upload csv file from user's computer to main server the code i am using is if(((isset($_GET)) && ($_GET=="yes")) ) { $typefield = $_GET; echo...
11
AutumnsDecay
by: AutumnsDecay | last post by:
Hey there. I've been implimenting FCKEditor into my clients websites so they can update the text and pictures on their own. The way it is currently setup is that you need to 'login' to gain...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.