I want to repeatedly zero a large 2d array in C. This is what I do at the moment:
// Array of size n * m, where n may not equal m
for(j = 0; j < n; j++)
{
I think that the fastest way to do it by hand is following code. You can compare it's speed to memset function, but it shouldn't be slower.
(change type of ptr and ptr1 pointers if your array type is different then int)
#define SIZE_X 100
#define SIZE_Y 100
int *ptr, *ptr1;
ptr = &array[0][0];
ptr1 = ptr + SIZE_X*SIZE_Y*sizeof(array[0][0]);
while(ptr < ptr1)
{
*ptr++ = 0;
}