Variable declaration after goto Label

前端 未结 7 2253
我在风中等你
我在风中等你 2020-12-04 15:20

Today I found one interesting thing. I didn\'t know that one can\'t declare a variable after a goto label.

Compiling the following code

#include <         


        
7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-04 15:36

    #include 
    int main() {
        int x = 5;
        goto JUMP;
        printf("x is : %d\n",x);
    JUMP:
        printf("Do anything after label but dont declare 
        anything. even empty statement will also work 
        because label can only be part of a statement");
        int a = 0;  
        printf("%d",a);
    }
    

提交回复
热议问题