Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!caen!uakari.primate.wisc.edu!aplcen!boingo.med.jhu.edu!haven!umbc3!gmuvax2!xwang From: xwang@gmuvax2.gmu.edu (Xiang-Min Wang) Newsgroups: comp.lang.c Subject: Re: Array question Message-ID: <3675@gmuvax2.gmu.edu> Date: 2 Mar 91 04:49:51 GMT References: <9304@hub.ucsb.edu> Reply-To: xwang@gmuvax2.UUCP (Xiang-Min Wang) Organization: George Mason Univ. Fairfax, Va. Lines: 26 email: xwang@gmuvax2.gmu.edu In article <9304@hub.ucsb.edu> tomkwong@banana.UUCP (Thomas K. Kwong) writes: >In article rg2c+@andrew.cmu.edu (Robert Nelson Gasch) writes: >> >> int *this_ptr; >> this_ptr [0] = 1; >> this_ptr [1] = 2; >> . . . >> this_ptr [9] = 10; >> >>This works fine, but I really don't know why?? It seems you're using >>memory to store an array which was never really allocated. Please notice that althouhg the pointer 'this_ptr', after declared, is not initialized by YOU (I am not sure the C compiler will initialize it to zero or not), it bears some value (as an address) ANYWAY. Therefore, you can do the "normal" things to it like the assignment: this_ptr[i] = i (or *(this_ptr+i) = i ) Simply speaking, your program is SYNTACTICALLY correct, but FUNCTIONALLY wrong. xwang internet: xwang@gmuvax2.gmu.edu bitnet: xwang@gmuvax.gmu.edu