This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]