char foo[] vs char *foo

utzoo!decvax!ucbvax!unix-wizards utzoo!decvax!ucbvax!unix-wizards
Fri Dec 11 04:18:10 AEST 1981


>From tjt at mit-vax@mit-xx Fri Dec 11 04:11:58 1981
The only time when char foo[] is equivalent to char *foo is as
parameters of a function.  char foo[] declares foo as an array of
characters of unspecified size.  The size of the array is determined
by the initialization string "bar".  However, in the context of
declaring function arguments, array types are converted to pointers,
thus promoting the popular fiction that the above two declarations
are equivalent.

Reference: "C Reference Manual" in "The  C Programming Language".
Section  8.4 pp194-5 and Section 10.1 pp204-5.



More information about the Comp.unix.wizards mailing list