I have 4 int arrays. They all have the same number of elements. Something like this:
int ar1[] = {1,2,3,4};
int ar2[] = {10,12,13,14};
int ar3[] = {8,9,15,16};
int ar4[] = {17,18,19,20};
int big[][] ={ar1,ar2,ar3,ar4}; // I know this is messed up but here is where the question lies
Is there a way so that when I run a for loop:
int i;
for(i =0; i<4; i++){
int x;
for(x = 0; x<4; x++){
printf(big[i][x]); // something like this
}
}
So that when this is executed, it prints out:
Array 1 : 1 2 3 4
Array 2 : 10 12 13 14
etc…..
Thanks.
Check this out: Multidimensional arrays in C and this Wikipedia page for the general information on multidimensional arrays in C.
Your code should work with this: