I am working with an array and am trying to find the first non zero value in the row focus, but when the program runs it says the first value in the row is not zero even when it is. Here is the section of the code that is not working:
leadingIsHere = 0;
goThrough = 0;
while(leadingIsHere == 0)
{
printf("Before, leadingIsHere: %d, goThrough: %d, array[focus][goThrough]: %lf\n", leadingIsHere, goThrough, array[focus][goThrough]);
if(array[focus][goThrough] != 0)
{
printf("It is happening and array[focus][goThrough]: %lf\n", array[focus][goThrough]);
leadingIsHere = 1;
leading = goThrough;
}//end of if
printf("After, leadingIsHere: %d, goThrough: %d, array[focus][goThrough]: %lf\n", leadingIsHere, goThrough, array[focus][goThrough]);
printf("Focus: %d, leading:%d, goThrough: %d array[focus][goThrough]: %lf\n", focus, leading, goThrough, array[focus][goThrough]);
goThrough++;
}
The printf's are just so I can actually see what all the values I'm working with are, and they show that at all points the value of array[focus][goThrough] is zero, but the part in the if statement still runs. Any help would be very appreciated, thank you.