c - 如何在 main() 外部的不同函数中使用 goto 函数

标签 c function goto

#include <stdio.h>

void Check (short);

int main()
{
    short a;`

    //[... code ...]

    List :

    //[... code ...]

    Check (a);

    //[... code ...]
}

void Check (short a);
{
    if (a == 1)
    {
        goto List;
    }
}

如何实现这样的用法?

前主

  • 我想进入列表

    - 函数跳转到main

  • 是的

  • 我是初学者
<小时/>
  1. 请回答我

最佳答案

这在 C 语言中是不可能的。

C 标准说,

The identifier in a goto statement shall name a label located somewhere in the enclosing function. A goto statement shall not jump from outside the scope of an identifier having a variably modified type to inside the scope of that identifier.

关于c - 如何在 main() 外部的不同函数中使用 goto 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42447494/

相关文章:

c - 如何在不丢失的情况下捕获所有 udp 消息,如 Wireshark?

javascript - 导出要在控制台运行的函数

goto - 使用带有开关的 goto vs while(wrongchoice)。

c - 在 for 循环中扫描用户输入

c - _mm_crc32_u8 给出与引用代码不同的结果

Javascript/Jquery 通过事件切换对象

这可以被认为是可接受的 goto 使用吗?

编译器设计代码来解析 goto 和 block

c - 内存不足

javascript - 如何将链函数从一个类添加到另一个类?