public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Eljay Love-Jensen <eljay@adobe.com>
To: "Ajay Bansal" <Ajay_Bansal@infosys.com>, <gcc-help@gcc.gnu.org>
Subject: Re: Problem with fread
Date: Tue, 20 May 2003 13:23:00 -0000	[thread overview]
Message-ID: <4.3.2.7.2.20030520081825.00b4f4a8@iplan-mn.corp.adobe.com> (raw)
In-Reply-To: <2B721C6525F0D411B1E900B0D0226BDD02AAE0AC@mohmsg01.ad.infos ys.com>

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

       reply	other threads:[~2003-05-20 13:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <2B721C6525F0D411B1E900B0D0226BDD02AAE0AC@mohmsg01.ad.infos ys.com>
2003-05-20 13:23 ` Eljay Love-Jensen [this message]
2003-05-20 13:15 Ajay Bansal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4.3.2.7.2.20030520081825.00b4f4a8@iplan-mn.corp.adobe.com \
    --to=eljay@adobe.com \
    --cc=Ajay_Bansal@infosys.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).