[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
> It is not that odd, since if strncpy detects a \0 before copied 'n'
> characters, it will fills with \0 the rest of the string, iow, this
> program:
Ok, but it's not that feature I'm complaining of (even if I find it
somewhat useless), but of the following one:
char str1[]="hello everybody";
char str2[6];
strncpy(str2, str1, sizeof(str2)-1);
According to my docs on the ANSI standard, str2 is *not* NULL-terminated,
whereas with:
str2[0]=0;
strncat(str2, str1, sizeof(str2)-1);
str2 is NULL-terminated.
--
Eric Botcazou
ebotcazou@xxxxxxxxxx