The code in lines 16-20 is all wrong. you need nested loops to do that, and array indices are the values of the loop counters, like this:
array[row][col] = 0;
Or even easier -- you don't have to do the above at all if you initialize the array when it is declared
int matrix[NO_OF_ROWS][NO_OF_COLUMNS] = {0};
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>>The compiler builds it and the output is ok
Yes the compiler will build it, but its not ok. What you have is called buffer overrun. Look at what you posted and THINK about it for a couple minutes. Why do I say buffer overrun -- because array element at indices matrix[NO_OF_ROWS][NO_OF_COLUMNS] does not exist. Your program is scribbling all over memory outside he boundries of the array.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343