我只是 C 编程的新手,我正在努力学习这门语言。但是当我编译代码时,我让它显示错误 “FuncA was not declared in this scope”
。但我已经尝试在下面声明函数。
#include<stdio.h>
int main(){
int A = 1;
FuncA(A);
printf("%d\n");
}
int FuncA(int B){
B++;
return B++;
}
抱歉这个问题。
最佳答案
你需要把它的声明:
int FuncA(int B);
在 main()
之前。
或者,您可以在函数定义之后移动 main()
。
P.S.:正如@JonathanLeffler 评论的那样,printf("%d\n")
是 undefined behavior :
If any argument is not the type expected by the corresponding conversion specifier, or if there are less arguments than required by format, the behavior is undefined. If there are more arguments than required by format, the extraneous arguments are evaluated and ignored.
你可能想要这个:
printf("%d\n", FuncA(A));
关于c - FuncA 未在此范围内声明 C 编程错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23018561/