Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site rlgvax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!rlgvax!guy From: guy@rlgvax.UUCP (Guy Harris) Newsgroups: net.lang.c Subject: Re: C declarations Message-ID: <442@rlgvax.UUCP> Date: Fri, 8-Feb-85 18:19:16 EST Article-I.D.: rlgvax.442 Posted: Fri Feb 8 18:19:16 1985 Date-Received: Sun, 10-Feb-85 04:01:21 EST References: <7699@brl-tgr.ARPA> <1752@pucc-h> <803@sjuvax.UUCP> Organization: CCI Office Systems Group, Reston, VA Lines: 15 > 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