Will using goto cause memory leaks?

前端 未结 10 2050
迷失自我
迷失自我 2021-01-17 11:33

I have a program in which i need to break out of a large bunch of nested for loops. So far, the way most people have been telling me to do it is to use an ugly goto in my co

10条回答
  •  一生所求
    2021-01-17 12:26

    No, you will not cause a memory leak. Using a goto is not "exiting loops improperly." It's just not generally recommended from a code-structure point-of-view.

    That aside, when you leave the loop, the local variables will go out of scope and be popped off of the stack (i.e. cleaned up) in the process.

提交回复
热议问题