I'm trying to initialise an array to a non-zero value:
BYTE byteArray[50];
memset(byteArray, 20, sizeof(byteArray)); // Works fine
int intArray[50];
memset(intArray, 20, sizeof(intArray)); // Does not work
For now, am just manually initialising the array:
// Initialise array manually
for (int pos = 0; pos < 50; pos++)
intArray[pos] = 20;
I do appreciate that memset
sets every byte in the memory range, so this cannot work the way I need for multi-byte types (except for the special case where the requested value is 0
). Is there a way to coerce memset
for non-zero values using multi-byte types or perhaps there is an alternate library function?