OK, I'm still very new to C++ and I am making/trying to make a battle ship game.
Everything had been going pretty well, until I added a function to check if a coordinate is already taken by another ship, my program just quit working. It still compiles and the command terminal comes up when I run it, but nothing happens.
The function I added is this:
If you don't think that this function is the problem. I can show you an instance where the function is used, or any other part of my code.Code:int check_taken ( string values, int num_aug ) { int shipcords[5]; int count = 0; while ( count < num_aug ) { int z; std::stringstream temp; temp << values.substr ( count,count+1 ); temp >> z; shipcords[count] = z; count++; } int samecords = 0; for (int ct=0; ct<5; ct++) { for (int cth=ct+1; cth<5; cth++) { if (shipcords[ct] == shipcords[cth]) { ct = 5; cth = 5; samecords = 1; } } } if ( samecords = 1 ) { return 1; } else { return 0; } }
Thanks,
David