there is a staff implementation of predefined set of moves for a 3 x 3 board which can be executed by ./fifteen 3 < ~cs50/pset3/3x3.txt I was working on my Won function, can some one tell me how do i work with gdb at the end of this command. I want to check my won function when all the moves are done and the board is set to a winning configuration
1 Answer
I found this little tidbit at this blog on Oracle that helped me a lot:
break WHERE if COND
If you've ever used gdb, you almost certainly know about the "breakpoint" command, which lets you break at some specified point in the debugged program.
But did you know that you can set conditional breakpoints? If you add if CONDITION to a breakpoint command, you can include an expression to be evaluated whenever the program reaches that point, and the program will only be stopped if the condition is fulfilled.
After running cs50's 3x3, if you look at the log.txt, you'll be able to find a pattern that's unique to the winning scenario, and you can pass it as a condition to the break.