相关疑难解决方法(0)

函数声明与定义C

我有一个简单的代码,我的函数在main函数之前声明:

int function1();
int function2();

int main() {
   /* ... */
   function1(x,y);
   function2(x,y);
   /* .... */
}

int function1(int x, float y) { /* ... */ }
int function2(int x, float y) { /* ... */ }
Run Code Online (Sandbox Code Playgroud)

在我的主要功能之后,我有函数的定义:

当我在main之前声明函数时,有什么不同吗?

int function1(int x, float y);
int function2(int x, float y);

int main() {
   /* ... */
   function1(x,y);
   function2(x,y);
   /* .... */
}

int function1(int x, float y) { /* ... */ }
int function2(int x, float y) { /* ... */ …
Run Code Online (Sandbox Code Playgroud)

c prototype declaration function definition

13
推荐指数
3
解决办法
3160
查看次数

标签 统计

c ×1

declaration ×1

definition ×1

function ×1

prototype ×1