PAGE2GO2 HOME | INTERNET NEWS

LeighExchange - Free Advertising Network Stock Research at Internet Speed

Re: How to load the whole file?

 List
Subject: Re: How to load the whole file?
Poster: roberson@ibd.nrc-cnrc.gc.ca(WalterRoberson)
Date: Fri, 23 Mar 2007 19:16:40 +0000 (UTC)
Related Postings: 1 2 3 4 5 6
In article <4604252b.392023@news.utanet.at>, Roland Pibinger wrote:
>On Fri, 23 Mar 2007 18:54:11 +0000 (UTC), Walter Roberson wrote:
>>In article <1174673995.436136.134030@l75g2000hse.googlegroups.com>,
>> wrote:
>>>Well, I want to read the contents of file in a character array.
>>
>>You cannot do it all at one time in C, as there is no C input
>>operation that will allocate memory and read the data at the same time.
>
>fseek, ftell, malloc??

That presumes that seeking is possible on the input. It also presumes that the input is a binary stream, as ftell returns an opaque token on text streams. Of course with binary streams, you have to do your own line termination conversions if the input was written as a text stream. And you cannot just fseek to the end of file on a binary stream (or at least implementations are not required to support WHENCE_END for binary streams.)

-- There are some ideas so wrong that only a very intelligent person could believe in them. -- George Orwell

 

Page2Go2.com is not responsible for content of this message.