I'm learning about arrays and functions for a school assignment, so i wrote a test program to check if i understood the theory, but when i print the array the output is wrong.
I just started learning and i honestly have no idea what i'm doing wrong.
Code:
#include <stdio.h>
#define TAMF 2
#define TAMC 3
void scanArray(int array[][]);
void printArray(int array[][]);
int main()
{
int array[TAMF][TAMC];
scanArray(array);
printArray(array);
}
void scanArray(int array[][])
{
int i,j;
for(i=0; i<TAMF;i++) {
for(j=0;j<TAMC;j++){
printf("Input array[%d][%d]:\n>", i, j);
scanf("%d", &array[i][j]);
}
}
}
void printArray(int array[][])
{
printf("\n------array------\n");
int i,j;
for(i=0; i<TAMF;i++){
for(j=0;j<TAMC;j++){
printf("%d\t",array[i][j]);
}
printf("\n");
}
}
For example, if i input:
1 2 3 4 5 6
It outputs:
4 5 6
4 5 6