gpt4 book ai didi

c - C11 是否允许在函数中的任何位置声明变量?

转载 作者:太空狗 更新时间:2023-10-29 15:49:05 25 4
gpt4 key购买 nike

C11 标准(注意我指的不是 C++11)是否允许您在函数中的任何位置声明变量?

以下代码在 ANSI C(C89、C90)中无效:

int main()
{
printf("Hello world!");
int a = 5; /* Error: all variables should be declared at the beginning of the function. */
return 0;
}

它是 C11 中的有效源代码吗?

最佳答案

是的。这在 C99 中已经有效(请参阅第二个项目符号 here)。

关于c - C11 是否允许在函数中的任何位置声明变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13111033/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com