This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


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

sprintf bug


Title: 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@adtech-inc.com     Adtech, Inc.    (808) 734-3300


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