[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Kill strcpy and strcat
From: |
Philip Kendall |
Subject: |
Re: [PATCH] Kill strcpy and strcat |
Date: |
Wed, 7 Nov 2007 13:37:33 +0000 |
User-agent: |
Mutt/1.5.12-2006-07-14 |
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;
There's the obvious difference that if strlen(some_string) <
sizeof(buf) - 1 then the snprintf() version won't set
buf[sizeof(buf) - 1] to zero, but I can't see how this makes any
difference in any real world use.
strncpy() is presuambly more efficient as well.
Cheers,
Phil
--
Philip Kendall <address@hidden>
http://www.shadowmagic.org.uk/
- [PATCH] Kill strcpy and strcat, Bastien Nocera, 2007/11/06
- Re: [PATCH] Kill strcpy and strcat, Pawel Kot, 2007/11/07
- Re: [PATCH] Kill strcpy and strcat, Daniele Forsi, 2007/11/07
- Re: [PATCH] Kill strcpy and strcat, Pawel Kot, 2007/11/07
- Re: [PATCH] Kill strcpy and strcat, Bastien Nocera, 2007/11/07
- Re: [PATCH] Kill strcpy and strcat, Pawel Kot, 2007/11/07
- Re: [PATCH] Kill strcpy and strcat, Bastien Nocera, 2007/11/07
- Re: [PATCH] Kill strcpy and strcat, Pawel Kot, 2007/11/07
- Re: [PATCH] Kill strcpy and strcat,
Philip Kendall <=
- Re: [PATCH] Kill strcpy and strcat, Pawel Kot, 2007/11/07
- Re: [PATCH] Kill strcpy and strcat, Ian Collier, 2007/11/07
- Re: [PATCH] Kill strcpy and strcat, Pawel Kot, 2007/11/07
- Re: [PATCH] Kill strcpy and strcat, Pawel Kot, 2007/11/07