Using a breakpoint
One way to test our suspicion is to force the loop to iterate
only four times.
To do so we first need to stop the loop after it has
iterated that many times.
dbxtra allows us to do this by letting us set breakpoints
within programs using the stop command.
(dbxtra) stop at 49 if player=3 [2] stop at "deal.c":49 if deal.deal_hands.player == 3Line 49 is the last line of the loop after all statements within it have been executed and if player is 3, we know that it has iterated four times. Rerunning the program now produces:
(dbxtra) rerun Dealing 1 hands... at 49: cardsleft = 52 at 49: cardsleft = 39 at 49: cardsleft = 26 at 49: cardsleft = 13 [2] stopped in deal_hands at line 49 in file "deal.c"To prevent the fifth iteration of the loop, we just need to increment player by one:
(dbxtra) assign player=player+1 (dbxtra) print player 4The counter has been incremented, so there will not be another pass when you continue the program.