Hi, started to learn multydimensional array, trying to transponse M[4][5] into N[5][4], compiler gives me an error but I still can't fix it, if anyone could help. Here is an error:
Code:
error C2143: syntax error : missing ')' before ']'
error C2059: syntax error : ')'
Here is my code
Code:
#include<stdio.h>
int M[4][5]={{1,2,3,4,5},
{6,7,8,9,10},
{11,12,13,14,15},
{16,17,18,19,20}};
int N[5][4];
void transposeMatrix(void)
{
int a=0, b=0;
for(a=0 ;a<4; ++a)
{
for(b=0; b<5; ++b)
N[b][a]=M[a][b];
}
}
void displayMatrix(void)
{
int a=0, b=0;
for(a=0; a<5; ++a)
{
printf("\n");
for(b=0; b<4; ++b)
printf("%5i", N[a]]b]);
}
printf("\n");
}
int main(void)
{
transposeMatrix();
displayMatrix();
}