scanf arrays

I'm actually learning C, but I know you can help me. (sorry for my poor english).
I'm using eclipse and I've tried to scanf into a 3d array (as a matrix). i always printf after scanf to look up what "the program is doing".
now, everytime I write 1 to 9 it gives me
1 2 4
4 5 2
0 2 0
back. Please find my mistake.
In addition to that, debugging dosen't work, too (*stopped,reason="end-stepping-range")

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//...
	int i = 0;
	int j = 0;

	int a[2][2];
	int b[2][2];
	int c[2][2];



	//Matrix A einlesen.

	puts("Bitte erste Matrix eingeben: \n");
	for(i = 0; i < 3; i++)		{
		for(j = 0; j < 3; j++)		{
			scanf("%d", &a[i][j]);
			printf("\t");
		}
		printf("\n");
}
//... 
Last edited on
you have declared your arrays to have 2 x 2 elements, the [2] is number of elements, not max index.


Topic archived. No new replies allowed.