gnokii-users
[Top][All Lists]
Advanced

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

correct snprintf implementation


From: BORBELY Zoltan
Subject: correct snprintf implementation
Date: Thu, 4 Apr 2002 00:36:53 +0200
User-agent: Mutt/1.2.5.1i

Hello,

On Wed, Apr 03, 2002 at 05:18:51PM +0200, Pawel Kot wrote:
>       exit (!(buf[2] == 0) && !(snprintf(NULL, 0, "%d", 100)));

It isn't correct (non C99 compliant snprintf will return -1).

> PS. Is the buf declaration valid or is it gccism?

    char buf[] = {0, 0, 0, 0};

is fully C compliant.

I managed to add a good GPL compatible snprintf implementation. It provides
snprintf/vsnprintf/asprintf/vasprintf implementation. The snprintf/vsnprintf
implementation is ISO C99 compliant. It will _always_ terminate the output
string, so everyone can rely on it.

Bye,
Bozo



reply via email to

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