My program keeps closing on me during this function of my code. I thought it might have my switch/case statement so I replaced it with if/else if/else statements and it still closes. If you guys could help me out I'd appreciate it.
I haven't seen it yet with the if statements but with the switch/case sometimes when I input like 'S' it would then respond with an action as if I input 'N' or something that was not 'S'.
This might just be me but, I'm assuming that something is breaking the do - while loop (which I'm confused as to why your not just using a while loop althought it shouldn't matter). Make sure that findCreature and safeDirection are false when the loop is about to iterate.
It's hard to say without being able to run the code. Try putting somebreak points in your code. If you don't know what those are or don't feel like learning about them just now, put some output statements in different parts of your code to see where the program is getting to (and where it's not getting to.
And you never see "checkpoint2" printed to the console, you know to look at my_crazy_function() a bit closer.
Give that a shot and report back if you still have issues.
Also, as far as 'S' acting like a non-'S', output the user entry just as a sanity check. Right before you begin testing the input, print it to the console to make sure it's what you expect. cin might act funny if you accidentally type in 'NS' instead of 'S', for example.
Alright I'm still not sure why it's doing this but I put in the checks and commented some unnecessary stuff out.
I put in a check after the cin two in each "north, east, south, west, two at the end of the do/while loop, a cin.get() and one after the do/while loop.
If I input a 'N', 'E', 'W', or 'S', my progrom doesn't show either of "check end1" or "check end2" nor does it do the cin.get();
*edit: Figured out the break; was making the "check end"'s not happen. as to why the program is closing i still don't know.
If I input a letter other than those though it does perform both of the "check end" and it does the cin.get(); and on the second time through the loop the program will close regardless of what I input.