gpt4 book ai didi

c - 如何在c的case语句中使用省略号?

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

CASE expr_no_commas ELLIPSIS expr_no_commas ':'

我在c的语法规则中看到了这样一条规则,但是当我尝试重现它时:

int test(float i)
{
switch(i)
{
case 1.3:
printf("hi");
}
}

它失败了......

最佳答案

好吧,这涉及到我的一些猜测,但看起来你在谈论一个 gcc C 的扩展,允许在 switch 中指定范围例。

以下为我编译:

int test(int i)
{
switch(i)
{
case 1 ... 3:
printf("hi");
}
}

注意 ...还要注意你不能打开 float .

关于c - 如何在c的case语句中使用省略号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5327896/

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