This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/16492] sprintf
- From: "aotto1968 at onlinehome dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Jul 2004 14:32:42 -0000
- Subject: [Bug c/16492] sprintf
- References: <20040712120839.16492.aotto1968@onlinehome.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From aotto1968 at onlinehome dot de 2004-07-12 14:32 -------
Hi,
the answer does not satisfy me, why ?
1. assume I have 10 bytes space not 11
the >char str[11]< 11'th char is just for displaying in the example
if I rewrite to > snprintf(str, 11, "%10p", 0x12345678);
the 11'th char was changed to \0 -> not allowed
if I rewrite to > snprintf(str, 10, "%11p", 0x12345678);
this does not help to
2. expand example:
#include <stdio.h>
int main (void)
{
char str[12];
str[11] = '*'; // do not overwrite that beast
str[12] = '\0'; // end of string
snprintf(str, 10, "%10p", 0x12345678);
// now I expect "0x12345678*"
printf("%s\n", str);
}
if possible for you, you can change upper code to something
>> exactly writing << an 10 byte ascii pointer to the string
without overwriting the boader's
thanks
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16492