C declarations

Guy Harris guy at rlgvax.UUCP
Sat Feb 9 09:19:16 AEST 1985


> 	My recollection from K&R is that in practice, strings and arrays of
> characters are supposed to behave the same way. Yet we all know this isn't
> true, and that some functions (e.g. strcpy) don't work right on one but
> work fine on the other.

Huh?  A "string" is a *null-terminated* array of characters, so not all
arrays of characters behave like strings (one thing the "strn..." routines
are useful for is for dealing with arrays of characters which may not
be null-terminated, i.e. a pseudo-string in a table which is either terminated
by a null character or by the Nth character).  "strcpy" won't work unless
the source string is null-terminated, so, indeed, it won't work on non-null-
terminated arrays of characters.

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy



More information about the Comp.lang.c mailing list