I have a piece of code that is supposed to fill a 2D array and print it out using pointers, the problem in stead I get only a part of it correct!
here is the code:
example:
I fill it with 1 2 3 4 I get: 1 -xxxxxx 3 -xxxxxx
Please help
here is the code:
Code:
#include <stdio.h> #define MAXROW 2 #define MAXCOL 2 main() { int i, j, T[MAXROW][MAXCOL]; //filling for(i = 0; i < MAXROW; i++) { for(j = 0; j < MAXCOL; j++) { printf("Please enter your value (%d,%d): \n", i, j); scanf("%d", T+i+(j*MAXROW)); } } //prompting for(i = 0; i < MAXROW; i++) { for(j = 0; j < MAXCOL; j++) printf("%d\t", T[i][j]); printf("\n"); } getch(); }
I fill it with 1 2 3 4 I get: 1 -xxxxxx 3 -xxxxxx
Please help
Comment