bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

snprintf bug


From: marten segerkvist
Subject: snprintf bug
Date: Mon, 26 Feb 2001 17:25:25 +0100 (MET)

typedef unsigned int size_t;
extern int snprintf  (char *   __s, size_t __maxlen,
                          __const char *   __format, ...)
     __attribute__ ((__format__ (__printf__, 3, 4)));

int main(void)
{
  char a[100] = "arne";

  snprintf(a, sizeof(a), "%s%s", a, "pelle");
  printf("%s\n", a);
}

gives the output 'arne' rather than the expected 'arnepelle'.

whereas in HP-UX 10.20 the same source code produces the exepected output.

example:
$ gcc bug.c -o bug
$ ./bug 
pelle
$ 

using libc version: libc-2.1.2 (modified redhat linux)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]