在调用的前一行复制粘贴函数头,然后加个分号。
比如函数体为
int pow(int a,int b)
{
}
那么在主函数体中添加为
int pow(int a,int b);
分两种情况
1 在同一个文件中
你只需要在main函数定义之前声明你的函数原型(prototype)就行,例如
int myfun(void);
/*declaration of a local function's prototype*/
int main(){
/*suite of main*/
return myfun();
}
int myfun(void){
/*suite of function myfun*/
return 0;
第二种情况是不在同一个文件之中
这时
int myfun(void);
就应该被换成
extern int myfun(void);
/*例如 gcc main.c myfun.c -omain.exe*/
就是这么简单,当然还有通过指定编译器选项的办法,这个可以在一些大型项目里见到,不具体列出