I'm learning about multidimensional array in C programming. But the printf function is not working. Here is my code:
#include <stdio.h>
int main (void)
{
int array[2][3][4];
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 4; j++)
{
for (int k = 0; k < 5; k++)
{
array[i][j][k] = k;
printf("array[%d][%d][%d] = %d\n", i, j, k, array[i][j][k]);
};
};
};
printf("Loop is finished!");
return 0;
}
int[2]means you have 2 elements, i.e. you can access indices 0 and 1, but you're accessing 2.