Hi,thanks all for the replies. I think it could be a stack overflow because previously the 2D array was 128 rows by 46 columns but when I expanded it to 1600 rows, the program crashed. So, if the the function parameters are replaced by pointers instead of arrays, will the crash problem be solved? I call the rank function using this: rank(n,d,distance,r); where n is the integer variable, d is the 2D array while distance and r are the 1D arrays.