V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
codechaser
V2EX  ›  C

C 中这样的代码块有什么作用?

  •  
  •   codechaser · 2019-04-04 22:42:00 +08:00 · 2596 次点击
    这是一个创建于 1820 天前的主题,其中的信息可能已经有所发展或是发生改变。
    int main(int argc, char** argv){
    	test : {
        	printf("Test.");
        }
        
        return 0;
    }
    

    这个test是干嘛的?

    5 条回复    2019-04-04 22:49:27 +08:00
    andyhuzhill
        1
    andyhuzhill  
       2019-04-04 22:44:23 +08:00
    标号
    可以使用 goto 跳转到这个个代码块
    cherishxzh
        2
    cherishxzh  
       2019-04-04 22:46:10 +08:00 via Android
    goto 语录的标签吧
    codechaser
        3
    codechaser  
    OP
       2019-04-04 22:46:45 +08:00
    @andyhuzhill 谢谢!想起来了!
    codechaser
        4
    codechaser  
    OP
       2019-04-04 22:46:53 +08:00
    @cherishxzh 谢谢!
    yuikns
        5
    yuikns  
       2019-04-04 22:49:27 +08:00
    http://cpp.sh/27p4r

    test 是标记开头。

    {} 可以定义局部变量。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5132 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 05:41 · PVG 13:41 · LAX 22:41 · JFK 01:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.