Mail Archives: djgpp/1999/10/17/11:43:11
flobere AT club-internet DOT fr wrote:
: > // Set each element of the kill list to 999
: > void empty_kill_list(int *list)
: > {
: > memset(list, 999, sizeof(int) * NUM_TILES);
: > }
: Hi,
: Very simple...
: the memset function prototype is :
: memset(void *ptr, char c, unsigned long size)
: The second arg is a CHAR. It means is in 8bits,
: it also means you cannot go over 255 using memset.
: That is why you cannot set your array to 999.
: Memset is only useful when you need to initialize an
: array to 0.
: It is not much more slower to use a for loop. The
: compiler will surely optimize it to a rep sto instructions.
Well, it's not _that_ simple. First I suggest you look at the
prototype or documentation for memset() (hint-hint-nudge-
youknowwhatImean-wink) before assuming anything.
But you are right that memset is used to set chars not ints (at least
in DJGPP and Linux).
Right,
MartinS
- Raw text -