Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Message-ID: From: "Jimen.Ching" To: cygwin AT sourceware DOT cygnus DOT com Subject: sprintf bug Date: Wed, 28 Jun 2000 16:45:32 -1000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01BFE174.1DCE6FEC" ------_=_NextPart_001_01BFE174.1DCE6FEC Content-Type: text/plain; charset="iso-8859-1" Hi all, I think there is a bug with sprintf in 1.1.2. The following is the code snippet that reproduces the bug: int maint(int argc, char *argv[]) { char buf[256]; double dbl = 0.0; sprintf(buf, "%4.3e\n", dbl); printf("%s", buf); /* buf contains garbage characters. */ return; } It seems if you have a non-zero value after the dot in the format, then sprintf includes that many garbage characters. In the above case, there are 3 garbage characters. --jc -- jimen AT adtech-inc DOT com Adtech, Inc. (808) 734-3300 ------_=_NextPart_001_01BFE174.1DCE6FEC Content-Type: text/html; charset="iso-8859-1" sprintf bug

Hi all,

I think there is a bug with sprintf in 1.1.2.  The following is the
code snippet that reproduces the bug:

int
maint(int argc, char *argv[])
{
  char buf[256];
  double dbl = 0.0;

  sprintf(buf, "%4.3e\n", dbl);
  printf("%s", buf); /* buf contains garbage characters. */

  return;
}

It seems if you have a non-zero value after the dot in the format,
then sprintf includes that many garbage characters.  In the above case,
there are 3 garbage characters.

--jc
--
jimen AT adtech-inc DOT com     Adtech, Inc.    (808) 734-3300

------_=_NextPart_001_01BFE174.1DCE6FEC--