Below is the function I copied to get the plz do tell us the simple method for this.....

int ** addmatrix(int **a,int x1,int y1,int **b,int x2,int y2)
	int i,j,**c;
	if(x1==x2 && y1==y2)

The simplest way to avoid this, on this forum, is to stay AWAY from "NIGHTS". He's a pointer fan, big time! ;)

Seriously, use indeces (aka indexes), instead of pointers. Let C handle the change from index to pointer value.

Are you trying to add up the whole array?


Your right. Pointers make me salivate.



Highly inefficient. malloc wastes tons of CPU to do its job, so use it as little as possible.

I'd suggest making one big array and performing math to divide it into rows and columns. Its faster than your code.

And by doing it that way you don't need nested for loops, you can just add the arrays in one for loop. That would make the code faster to execute, more efficient, and less lines of code.