Re: Reading text file contents to a character buffer
- From: Ian Collins <ian-news@xxxxxxxxxxx>
- Date: Tue, 03 Aug 2010 11:27:53 +1200
On 08/ 3/10 11:16 AM, Ben Bacarisse wrote:
"BGB / cr88192"<cr88192@xxxxxxxxxxx> writes:
personally, I would just be like "to hell with it" and just use fseek/ftell,
since there is almost no way that a text file is going to be larger than 2GB
and expected to just be read into memory like this (it wouldn't fit on 32
bit systems anyways...).
Putting aside the issue of pedantry, it is worth pointing out that ftell
does not report the correct size to read in a whole text file on some
very common platforms. It may usually be a "safe" lie (i.e. you
get told a size larger than required) but it is, none the less, not the
size you need to read.
But on those systems there isn't a direct way of determining the correct size to read without scanning the file. Provided the code doesn't expect the result of a read to exactly match the size requested, all should be well.
--
Ian Collins
.
- References:
- Reading text file contents to a character buffer
- From: Navaneeth
- Re: Reading text file contents to a character buffer
- From: Ben Bacarisse
- Re: Reading text file contents to a character buffer
- From: BGB / cr88192
- Re: Reading text file contents to a character buffer
- From: Ben Bacarisse
- Reading text file contents to a character buffer
- Prev by Date: Re: Mixing size_t and other types
- Next by Date: Re: "claim", etc. (was Re: C Standard Regarding Null Pointer Dereferencing)
- Previous by thread: Re: Reading text file contents to a character buffer
- Next by thread: Re: Reading text file contents to a character buffer
- Index(es):