[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sprintf usage
From: |
Pawel Kot |
Subject: |
Re: sprintf usage |
Date: |
Fri, 5 May 2006 22:55:49 +0200 |
Hi,
On 5/5/06, E. Rosten <address@hidden> wrote:
> There seems to be a problem with gnokii sources and some compilers. I
> got the report from FC4 and gcc version 4.0.2 20051125. The problem is
> with interpretation of:
> sprintf(buffer, "%s%d", buffer, digit);
> It used to work so far but under FC4 it behaves always in the was as
> buffer was empty (regardles of buffer contents) and the result string
> is always the digit.
What is the expected benaviour? Is it essentially appending %d digit to
the end of the buffer.
That is expected behaviour. But in the case above it is always the
last appended digit (ie. one char).
> Is it a bug in gcc or is it misuse of sprintf?
These things tend to be quite ill specified in the standard, so I would
expect that it is a misuse. The bast place to ask is probably
comp.lang.c.moderated
Well, I already changed this to I think safe solution. But thanks anyway.
Also, wouldn't it be better to use snprintf as a general rule?
It is, but doesn't solve the problem.
take care,
pkot
--
Pawel Kot
http://www.gnokii.org/