This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Problem with fread
- From: Eljay Love-Jensen <eljay at adobe dot com>
- To: "Ajay Bansal" <Ajay_Bansal at infosys dot com>, <gcc-help at gcc dot gnu dot org>
- Date: Tue, 20 May 2003 08:23:28 -0500
- Subject: Re: Problem with fread
Hi Ajay,
fread does not append a '\0' (null character) at the end of a buffer.
Regarding your test_fread.cpp attachment...
You shouldn't use #include <string.h>, you should use #include <cstring>.
You shouldn't use #include <stdlib.h>, you should use #include <cstdlib>.
You shouldn't use #include <errno.h>, you should use #include <cerrno>.
I strongly urge you to consider using string objects and the #include
<string> header, instead of fixed character buffers.
I strongly urge you to use fstreams and #include <fstream>, instead of
FILE, fopen, stat, et al.
I strongly urge you to use C++ new/delete instead of C
malloc/calloc/realloc/free.
I'll send you my refactoring of your test_fread.cpp shortly. (Not to the
forum.)
Sincerely,
--Eljay