Help...

Joe English jeenglis at girtab.usc.edu
Tue Oct 10 15:27:47 AEST 1989


rang at cs.wisc.edu (Anton Rang) writes:
>[ This is not a flame, just a clarification, OK? ]
>
>There is no difference between "char h[]" and "char *h" in a
>declaration; they do exactly the same thing.  This program fails
>because there is no storage allocated for the string.

To clarify your clarification, char h[] and char *h
are different in some contexts.  Most noticeably,

/* in file foo.c */

char *h;

/* in file bar.c */

extern char h[];

will break.  char *h; says that the object stored at
&h is a pointer to char(s).  char h[]; says that the 
object stored at &h is itself a char (or vector thereof).

In the declaration of a function argument, they are
indeed the same, but as a local variable they are not.
(Is 'char h[]' as a local variable even legal?  If so,
what does it mean?)


--Joe English

  jeenglis at nunki.usc.edu



More information about the Comp.lang.c mailing list