2015年5月21日 星期四

goto Label用法解說

以下sample code為goto label使用方式,如下

#include <windows.h>
#include <stdio.h>
int main()
{
int n=7;
number2:
printf("hello world\n");
if (n==7)
{
n=8;
printf("n=7 start\n");
goto number0;
printf("n=7 end\n");
}
else
{
printf("n=8 start\n");
goto number1;
printf("n=8 end\n");
}

number0:
printf("hi number0\n");
goto number2;
number1:
printf("hi number1\n");
number3:
printf("number3\n");
system("pause");
return 0;
}



輸出结果


注意
使用goto都一定會跑goto寫的程式

ref:
http://blog.csdn.net/shimazhuge/article/details/8448773

沒有留言:

張貼留言