Newsgroups: comp.lang.c Path: utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Subject: Re: Array question Message-ID: <1991Feb10.050642.8660@zoo.toronto.edu> Organization: U of Toronto Zoology References: Date: Sun, 10 Feb 1991 05:06:42 GMT In article rg2c+@andrew.cmu.edu (Robert Nelson Gasch) writes: >What happens if I do the following? Basically I don't really understand >*why* this works: > > 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... Precisely correct. What is happening is that on your machine, whatever value this_ptr happens to get as its initial value happens to point to some memory that you are allowed to write on. You're scribbling on a random piece of memory, and random things could happen as a result. Well-designed machines try to make this a catastrophic error. -- "Read the OSI protocol specifications? | Henry Spencer @ U of Toronto Zoology I can't even *lift* them!" | henry@zoo.toronto.edu utzoo!henry