X-ROUTED: Sun, 17 Oct 1999 10:46:06 -0500 Message-ID: <3809E098.41165890@greenbelt.com> Date: Sun, 17 Oct 1999 10:43:36 -0400 From: Ed James Organization: GIAC X-Mailer: Mozilla 4.51 [en] (WinNT; I) X-Accept-Language: en MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: What's wrong with this code snippet ? References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com First guess is...You pass to memset an array of INT, but my def of memset states that is "sets each BYTE in the block...yadayadayada". so....you're initializing kill_list on a byte by byte basis, rather than an int by int, which is what you seem to want to do. Kevin wrote: > Hi all. > > yet another dumb question, but I can't seem to spot > where I'm going wrong. > > const int NUM_TILES = 320; // This is global > > int kill_list[NUM_TILES]; // This isn't > > empty_kill_list(kill_list); > > // Set each element of the kill list to 999 > void empty_kill_list(int *list) > { > memset(list, 999, sizeof(int) * NUM_TILES); > } > > this doesn't set any of the kill list elements to 999, > when I look at them, they appear to have been set to > some unfeasably large negative number. > > using a for loop to set the elements works fine, but is > probably much slower. > > Any ideas ? > > Kevin.