gpt4 book ai didi

c - C 中参数的默认值

转载 作者:行者123 更新时间:2023-12-04 06:13:10 26 4
gpt4 key购买 nike

假设我在 C 中定义了一个函数:

bool check ( int x, int y);

现在,如果我使用 check(4);

调用它

y 的取值是多少?

最佳答案

只有当函数未声明 (C89/90) 或声明时没有原型(prototype)(C89/90 和 C99)时,这样的代码才有可能编译。

在任何情况下,行为都是未定义的。如果调用中使用的提升参数的数量和/或类型与函数定义中使用的不匹配,则行为未定义。

6.5.2.2 Function calls

6 [...] If the number of arguments does not equal the number of parameters, thebehavior is undefined [...] If the function is defined with a type that does not include a prototype, and thetypes of the arguments after promotion are not compatible with those of the parametersafter promotion, the behavior is undefined

关于c - C 中参数的默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11694705/

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