pointer problems, help!

Wayne Throop throopw at sheol.UUCP
Sun Mar 24 13:37:31 AEST 1991


- hagins at gamecock.rtp.dg.com (Jody Hagins)
--   char filename[80],carriage_return[5];
- This means that you are setting aside enough space for 80 chars, and
- that memory has a starting address.  The starting address is stored in
- the variable <filename>.

No, that's not what it means.  The starting address of the array (by
which is probably meant the address of the first element, BTW: an
important distinction to make in C) is not stored anywhere in runtime
memory by this declaration, least of all "in" the variable named
"filename". 

Where do these myths come from, anyhow?

What the declaration of filename above means in C is that space for
eighty characters is set aside, and this space is given the name
"filename".  (It might mean something different as a formal
argument declaration, but that's not what it was in the example.)

- I do think you need to go back to
- your text, and instructor, and get a grasp on the difference between a pointer
- and the data the pointer is referencing.

This comment, on the other hand is correct.  Another possible expression
of the problem in the original post is that NULL should not be used to
assign values to or to compare with characters, but rather pointers.
--
Wayne Throop  ...!mcnc!dg-rtp!sheol!throopw



More information about the Comp.lang.c mailing list