gnokii-users
[Top][All Lists]
Advanced

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

Re: [PATCH] Kill strcpy and strcat


From: Pawel Kot
Subject: Re: [PATCH] Kill strcpy and strcat
Date: Wed, 7 Nov 2007 16:23:39 +0100

Hi,

On Nov 7, 2007 2:42 PM, Ian Collier <address@hidden> wrote:
> On Wed, Nov 07, 2007 at 02:26:40PM +0100, Pawel Kot wrote:
> > Maybe somebody could tell me if there is a difference between:
> > snprintf(buf, sizeof(buf), "%s", some_string);
> > and
> > strncpy(buf, some_string, sizeof(buf));
> > buf[sizeof(buf) - 1] = 0;
>
> strncpy always fills the whole buffer (it pads shorter strings with
> nul bytes) and so is potentially slightly slower, although of course
> snprintf has the overhead of interpreting the format string.

Yeah. You are probably right. Thanks for the answer.

take care,
pkot
-- 
Pawel Kot




reply via email to

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