Thursday, July 30, 2009

In Visual Studio 2005, how can I run until a variable changes?

I have a loop in my program. At the beginning of the loop, a certain variable consists of letters. At the end of the loop, the loop consists of digits. Inside the loop, I never intentionally change the variable-- I believe it's getting "stepped" on. I process this loop more than a thousand times when I run the program, so it would not be economical for me to trace the program through to the iteration in which the variable is getting changed (and I don't know which iteration it is, anyway). I'd like to put a "watch" on the variable (which I've already done, actually) and then run the program until the variable changes so I can see where it's accidentally getting stepped on.





How do you do this in Visual Studio 2005? It's a C++ program, if that makes any difference at all.

In Visual Studio 2005, how can I run until a variable changes?
Have you tried using a breakpoint in the IDE when you are debugging your code? You COULD see what iteration it changed on in runtime if that isn't possible.





Pseudocode...





bool initialStore = 1;


iteration = 0


do


iteration++


if initialStore = 1


// Store initial variable


initialstore = 0


else if initalStore = 0 AND var != initVar


print iteration


loop


No comments:

Post a Comment