I'm working on my class project and I'm currently stuck at the most basic one. Basically I have to fill the stack of boxes using loops and 3d array. The stack is 4 width, 4 length and 3 height and I have to fill boxes with 100 items each.
void main(){
int boxShleve[3][4][4];
int i, j, k;
for (i=0; i<3; ++i){
for (j=0; j<4; ++j){
for (k=0; k<4; ++k){
boxShleve[3][4][4] = 100;
}
}
}
printf("%d", boxShleve[3][4][4]);
}
This is the broken piece of my work... How do I make each array has 100 element in it?
i,jorkas indexes in the array. Instead you have the size as index, and as you (should) know arrays are indexed from zero to size minus one, so those indexes are all out of bounds.int box[4];initialize them properly and thenprintf("%d", box[4]);when you have 0 indexing.printf("%d", boxShleve[3][4][4]);-->printf("%d", boxShleve[2][3][3]);