I Have a code that fails abruptly after going through several hundred times around a for loop. (The loop is not over yet . I can see that from my printed output)

Pinpointing the exact location (line number) and variables at that point of failure can provide me with useful information. But I don't know how to extract it.

(I can't use the conventional step into + F10 method, as pressing F10 several 100 times during the loop would be tedious).

I am using microsoft visual C++ 2008 (express edition).

Thanking You in advance !

Once you have a breakpoint set, you can step through a few lines as needed and then hit F5 (or Continue in the debug menu or the green "play" button on the toolbar) and it will cycle through until it hits the breakpoint again.

I think my code fails in 1 of the lines within the loop. So if I set a break point (which will have to be somewhere inside the loop), then I will have to press play button several thousand times before I hit my point of failure.

I know in some old compilers you could press ctrl+C (as interruption signal) > followed by print comands to find the values of different variables.
Doesn't work in visual c++ though :(

Or put an if statment in

if (iterations greater than 1000 && it's Wednesday)
                cout <<"Super";

and set a breakpoint at the second line. I think the fancier versions of VS have conditional breakpoints but I don't believe the EEs do.

Of course the low-tech version would be to output relevant results to the terminal (and redirect output to a txt) or write to a file directly -- then use your favorite text editor to search for the conditions you seek.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.