Hi, In a graph problem, I need to memset a whole 2D array with a large value that denotes INFINITY.
Currently, I am doing this by running a O(N*N) loop.
for(int i=0;i<maxx;i++){
for(int j=0;j<maxx;j++){
grid[i][j] = large_value;
}
}
Is there a better way to do this?
Also, I have tried memset
function. memset(grid,127,sizeof grid)
resets all values to 2139062143
memset(grid,128,sizeof grid)
resets all values to -2139062144
Why memset works like this? Thanks in advance!