I'm running into trouble again
This time I'm attempting to store the lowest row value of the columns to an int array, so I can keep track of the next piece dropped into that column. Here is my test code for the first column (since I'm dealing with a single array of length 42, the first column starts at position 0 and ends at 35, with 7 unit increment each time):
Code:
int top[7]; //declaring the array that will holds the position
//of the lowest empty row of each column
// printf("size is: %d \n", sizeof(top));
// printf("first element is: %d \n", top[0]);
int top_0;
for (top_0 = 35; top_0 >= 0; top_0-=7){
if (grid[top_0] != '-') {
top_0+=7;
top[0] = top_0;
break;
}
}
I'm looping through the 6 rows of the first column starting at index 35 (the highest position), with a decrement of 7 each time. If a slot is found to be occupied, then the lowest empty row is right above it, so I would return that index + 7. That number will finally be assigned to the first index of the int array top, which is top[0]. I tried to compile it but it didn't work. Thanks for your help in advance guys !