#include<stdio.h>
int falge = 1;
void my_init( void )
{
int count = 0;
if ( falge == 1 ) {
goto that;
} else {
goto those;
}
//those: printf("This is goto those!\n");
that: printf("This is goto that!\n");
count++;
if ( count == 3 )
those: printf("This is goto those!\n"); goto that;
exit: printf("exit goto!\n");
}
void main( void )
{
my_init();
int falge = 1;
void my_init( void )
{
int count = 0;
if ( falge == 1 ) {
goto that;
} else {
goto those;
}
//those: printf("This is goto those!\n");
that: printf("This is goto that!\n");
count++;
if ( count == 3 )
goto exit;
//break 这个break 是不合法的! 但是如果没有此处的if 判断 这是一个死循环! 不能使用break的死循环
those: printf("This is goto those!\n"); goto that;
exit: printf("exit goto!\n");
}
void main( void )
{
my_init();
}
感觉goto语句蛮好玩
而且长得很奇怪:
0,执行完
that: printf("This is goto that!\n");
会接着执行
those: printf("This is goto those!\n");
1,注意those也是一个标号,而且执行呢!
猜测:goto的标志 是不是编译器记录了标记处cs:ip,那么这个过程应该发生在编译的时候,是不是很像 汇编里面的jmp?