Debugging loops in Micosoft Visual C++ 2010 Express

This is a discussion on Debugging loops in Micosoft Visual C++ 2010 Express within the C++ Programming forums, part of the General Programming Boards category; Hi, I am debugging a for loop which is 100 iterations long. My program starts to struggle after 50th loop, ...

  1. #1
    Registered User
    Join Date
    Sep 2010
    Location
    London
    Posts
    41

    Debugging loops in Micosoft Visual C++ 2010 Express

    Hi,

    I am debugging a for loop which is 100 iterations long.
    My program starts to struggle after 50th loop, so I need to take a look inside each step of the loop after 50th iteration.

    Currently the only way I know to skip through a loop iteration is to say 'run to cursor' just before end of the loop, so it skips one iteration then do it again so it will skip the second etc

    As you can appreciate this will take a very long time until I reach the 50th iteration.

    Is there a way to skip a user defined number of iterations and go to the one I need straight away???

    Thank you!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,401
    That depends on what the loop actually does... but logically, if you can skip the first 49 iterations and still get the same net effect, then you probably should do that even if you were not trying to debug for the 50th iteration (e.g., you use a formula instead of a loop).

    Why not post the loop and other necessary code?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Sep 2010
    Location
    London
    Posts
    41
    My friend just told me the answer:

    Place a breakpoint just before end of the loop,
    Right click on the breakpoint
    Choose 'Hit Count' option
    specify to break when hit count reaches 50.

    Works a treat!

    Thank you for your comment anyway.

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,422
    You can also set a breakpoint with a condition, say, i==50. That would break at a specific time in a loop. Also handy.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Sep 2010
    Location
    London
    Posts
    41
    Thank you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Visual C++ 2010 express problems
    By dnj23 in forum Windows Programming
    Replies: 6
    Last Post: 08-10-2010, 06:16 AM
  2. Visual Studio 2010 Express vs 2005 Standard
    By micahharwell in forum Windows Programming
    Replies: 6
    Last Post: 06-13-2010, 07:45 AM
  3. Using 'if' with char arrays or string objects
    By c++_n00b in forum C++ Programming
    Replies: 36
    Last Post: 06-06-2002, 09:04 PM
  4. odd errors from msvc std library files
    By blight2c in forum C++ Programming
    Replies: 6
    Last Post: 04-30-2002, 12:06 AM
  5. <list>
    By Unregistered in forum C++ Programming
    Replies: 9
    Last Post: 02-24-2002, 03:07 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21