allocate sufficient space for tab1[], tab2[], and tab3[] in your calling function according to the values of n and m...you can pass the double-dim array to the fuction as *mat