Sorry, a guy at work told me about this, but I didn't believe him, and
now I do but don't understand it. Searching google and google groups
didn't turn up what I was looking for, was hoping maybe somebody here
would know.
For the below code, running it in gdb, set a breakpoint for line 5. GDB
breaks only once, the first time it hits line 5, and then finishes up
and exits the program. I think it should stop on line 5 for every loop.
But it doesn't. But maybe I've got something set up wrong.
I'm guessing that gdb is only breaking on the "x = 0" part of the code,
and since that only happens once, it's not breaking on that line again.
The guy who told me about this showed me what he was doing, he's just
going through the debugging section of this linux programming book, and
in the book it shows gdb breaking on the for loop at every iteration.
But I dunno.
1
2 int main()
3 {
4 int x = 0;
5 for(x = 0; x < 10; x++)
6 {
7 printf("the value of x is %i\n", x);
8 }
9 return 0;
10 }
11