On Feb 19, 12:45 am, "Bill Cunningham" <nos...@nspam.com> wrote:
> > Keep enlarging the buffer (with realloc()). When you get end-of-file,
> > reduce the size of the buffer to the size of all the data actually
> > read. Or read the file in pieces and never try to have the whole
> > file in memory at one time.
>
> So I'll need a buffer for fread and write.
> char buff(10);
> And a pointer for realloc
> char *b=&buff;
> Something like that right?
No, not something like that, and you know it.
It is not a learning issue when you have 'char buf(10);' or 'char
*b=&buff' in your code.
It's a matter of lazyness or you are trying to troll. It wouldn't
compile.
You want to raise discussions over why would one put a whole file in
memory or why ftell() is not reliable et cetera.
As it's been told to you before: either put the whole file in memory
OR read it in chunks/blocks.
Do not further ask here how to do that, go read about
malloc(),realloc(),fread(),fseek(),ftell() (the latter two, you don't
even need)
If you don't understand what these functions do or return, don't ask
here, read about them again.
And in your future posts, please avoid mentioning assemblers, file
formats and operating systems.
That is, if you are not troll.
|