So long story short... i am new to C and in a class right now that is challenging me in a lot of areas.
I am trying to figure out what to pass and how to test my code through the Main function. I want it to print out the numbers of my A[j][i] as i am using memory pointers but can never seem to get the code to compile... Any help would be great. (I am going to office hours today so jut trying to understand more beforehand)
Thanks,
Kuz
Code:
include <stdlib.h>
#include <stdio.h>
#define M 52
typedef int Marray_t[M][M];
void transpose(Marray_t A)
{
int i,j;
for(i=0; i<M; i++)
{
int *Aji = (int *)A + i;
int *Ai = (int *)A + (M * i);
for(j=0; j<i;j++)
{
int t = *Aji +i; // to to store the pointer of
*(Aji + i) = *Ai; // store the value of another pointer *Ai
*Ai = t; // then store the value of t
*Ai = *Ai + M; //
}
}
for(i = 0; i < M; i++)
{
for(j = 0; j < M; j++)
printf("%d\t", A[i][j]);
}
}
int main() // My Main function to print out the numbers in A[j][i]
{
int i,j;
for(i=0; i<M; i++)
for(j=0; j<M; j++)
{
printf("%d\t", A[j][i]);
printf("\n");
return 0;
}
}