Transposing a matrix
- by ZaZu
Hello,
I want to transpose a matrix, its a very easy task but its not working with me :
int testtranspose(testing *test,testing *test2){
int i,j;
(*test2).colsmat2=(*test).rowsmat1;
(*test2).rowsmat2=(*test).colsmat1
for(i=0;i<(*test).rowsmat1;i++){
for(j=0;j<(*test).colsmat1;j++){
((*test2).mat[i][j])=((*test).mat[i][j]);
}
printf("\n");
}
}
I thought this is the correct method of doing it, but apparently for a matrix such as :
1 2
3 4
5 6
7 8
I get :
1 2 0 0
3 4 0 0
What is the problem ?
Please help,
Thanks !