How to change initial iterator value of my loop to debug in VScode?
Example: I want debug my code starting i=10. How do I do to select this argument to my debugging? I’m loosing so many time clicking in "Step Over" to investigate my code. I’m using language C
3
Answers
You can do so by either taking the user input –> i (that’s inefficient) or else you can change i while debugging in vs code
Here is a image for reference
But incase you only want to check when i is k(some constant) without skipping the iterations below it(when i<k), you can use
if(i>=k){code}
Another option is a conditional breakpoint. Its condition can be when
i
has a specific value.The big advantage is: you don’t need to recompile your code.
The universal quick & dirty solution no matter debugger is to modify the code. For example:
It’s also good practice to surround such "debug only" code with a so-called "compiler switch":
#ifdef DEBUG_MODE ... #endif
. So that you don’t forget to remove the code and it makes it to release build by accident (very common problem).