Hey guys,
I was wondering if there is an *efficient* way in setting every pointer in an array of pointers to NULL?
memset cannot work for compatibility reasons, but I was playing a bit with memcpy: I built an array of NULL-pointers and tried to memcopy it to the array I wish to clear, but I couldn't find a working solution.
e.g.:
int** NULL_ARRAY;
NULL_ARRAY = (int **) malloc (x * sizeof(int*));
int** array;
array = (int **) malloc (x * sizeof(int*));
// fill array with sth.
memcpy(array, NULL_ARRAY, x);
doesn't work either with e.g.: memcpy(&(array[0]), &(NULL_ARRAY[0]), x);
or: memcpy(array[0], NULL_ARRAY[0], x);
Does anybody know a method which avoids a loop? Would be much appreciated. thx in advance!
And a bit related to that: is there also a one-instruction routine for setting every member of an array of ints to a special value not equal to 0?
best, Joerg