delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/17/12:25:22

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 <edjames AT greenbelt DOT com>
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: <c6wJONRNMABaX1eVyyz+aTSlhqUz AT 4ax DOT com>
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.



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019