dynamic array of pointers, how to initialize quickly?
I still have trouble understanding how to handle initialization of an array when its very large and unmanageable, i am trying to test out memset function to see if that will do the trick.
I have an array of pointers for a 'multidimensional array' ..I need the something that will do this here..without a loop that takes so much time.
size of len1 will be around ~250,000
Code:
int **dp = new int*[2];
for(int i=0;i<2;++i)
dp[i] = new int[len1+1];
// Really need a faster solution for this!...250,000*2 loops is no good.
for(int i=0;i<2;++i)
for(int j=0; j<len1+1;++j)
dp[i][j] = 0;
how can I use memset to place 0's in every spot of this kind of array?
I see this example somewhere..for normal array.
But, it gets complicated with pointer array of pointers...bleh
Code:
memset (an_array, 0, sizeof(an_array));
any ideas? should I be using memset?
Thanks a ton!