Is it ever advantageous to use 'goto' in a language that supports loops and functions? If so, why?
问题 I've long been under the impression that goto should never be used if possible. While perusing libavcodec (which is written in C) the other day, I noticed multiple uses of it. Is it ever advantageous to use goto in a language that supports loops and functions? If so, why? 回答1: There are a few reasons for using the "goto" statement that I'm aware of (some have spoken to this already): Cleanly exiting a function Often in a function, you may allocate resources and need to exit in multiple places