I want to memset a 2D array to 0. Here\'s my code.. But it always giving me seg fault;
bool **visited=new bool*[m];
for(int i=0;i
Your array is not contiguous since it is not actually a multi-dimensional array. It's an array of arrays, sometimes known as a jagged array.
So, your rows can, and will, be disjoint. Hence you'll need to call memset on each row.
bool **visited=new bool*[m];
for(int i=0;i
Although, I can't refrain from pointing out that you should probably be using C++ features rather than writing what appears to be C with the use of the new operator.