Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!seismo!beno!black From: black@beno.CSS.GOV (Mike Black) Newsgroups: comp.lang.c Subject: Re: difference between 'char *arr' and 'char arr []' Keywords: pointers Message-ID: <49140@seismo.CSS.GOV> Date: 9 Oct 90 21:47:17 GMT References: <151805@felix.UUCP> <1990Oct4.234406.17473@alzabo.uucp> Sender: usenet@seismo.CSS.GOV Organization: Center for Seismic Studies, Arlington, VA Lines: 19 Another quote from K&R original reference (Appendix A, paragraph 7.1): "The expression E1[E2] is identical (by definition) to *((E1)+(E2))..." 2 paragraphs later, "...array names are CONVERTED to pointers" (my emphasis). A seeming conflict for something that is identical. I got bit on this trying to port some software to MicroSoft C. It indeed contained struct a[] in one section and struct *a as an extern in another. It worked on an Amiga, Sun, and Dec 3100, but not on the PC. Here's where K&R says it (App A, par 14.3): "Every time an identifier of array type appears in an expression, it is converted into a pointer...". Ergo, an extern of type pointer will not get converted and unless type pointer and type array are equal will cause problems. Mike... -- ------------------------------------------------------------------------------- : usenet: black@beno.CSS.GOV : land line: 407-494-5853 : I want a computer: : real home: Melbourne, FL : home line: 407-242-8619 : that does it all!: -------------------------------------------------------------------------------