[Info-vax] strncpy(), was: Re: Whither VMS?
Richard B. Gilbert
rgilbert88 at comcast.net
Sat Oct 3 16:28:04 EDT 2009
Simon Clubley wrote:
> On 2009-10-03, Mark Daniel <mark.daniel at wasd.vsm.com.au> wrote:
>> strncpy() may not overflow but then it does not terminate the copied
>> chars when that happens either. The whole null-termination approach is
>> a crock (much as I use it).
>
> I've made it a point to _always_ place a null in the past position of a
> buffer after a call to strncpy() for exactly that reason.
>
> IMHO, whoever specified the strncpy semantics deserves to be shamed.
>
Well, perhaps. But who said you had to use strncpy? Or C? You can
certainly write your own string copy routine and try to do it better.
It is a poor craftsman who blames his tools!
More information about the Info-vax
mailing list