Ok. I've run this through gdb (with my rather limited knowledge of it), and have tried going through and looking at all the parts of the code that I could think of that might be causing the problem.
What the code is supposed to be:
choose5.c is a 'guesser' for a game of battleship. It gives the next guess, and is fed the Status of the last guess (which are in an enum in the battleship.h).
testRun3.c is a way for me to test how choose5.c is working. If choose5.c chooses a space with a ship on it, that ships counter is incremented until it reaches the size of the ship, and the Status is returned as SUNK(Ship name).
This is where (one) of the problems lies. Battleship is getting incremented when *nextRow is 8 and *nextColumn 0.
The weird thing is, Battleship only takes up Row 8, Columns 4,5,6,7
testRun3.c
Code:
if(*nextColumn == 0)
{
if(*nextRow == 7 || 8 || 9)
{
Submarine++;
if(Submarine == 3)
{
result = SUNKSubmarine;
}
}
}
if(*nextRow == 5)
{
if(*nextColumn == 4 || 5 || 6)
{
Frigate++;
if(Frigate == 3)
{
result = SUNKFrigate;
}
}
}
if(*nextRow == 8)
{
if(*nextColumn == 4 || 5 || 6 || 7)
{
Battleship++;
if(Battleship == 4)
{
result = SUNKBattleship;
}
}
}
So at the same time, both Submarine row[7,8,9] column[0] and Battleship are incremented.