c语言中怎么定义第三方函数
答案:2 悬赏:10
解决时间 2021-11-16 12:14
- 提问者网友:临风不自傲
- 2021-11-15 17:03
c语言中怎么定义第三方函数
最佳答案
- 二级知识专家网友:撞了怀
- 2021-11-15 18:21
先声明你要写的第三方函数,之后,把函数写在下面就行了。举例:
#include <stdio.h>
void fun(); //定义声明函数
int main()
{
fun(); //主函数里面使用/调用该函数
return 0;
}
void fun() //写的第三方函数
{
printf("hello word");
}
#include <stdio.h>
void fun(); //定义声明函数
int main()
{
fun(); //主函数里面使用/调用该函数
return 0;
}
void fun() //写的第三方函数
{
printf("hello word");
}
全部回答
- 1楼网友:大漠
- 2021-11-15 19:48
给你个例子
#include<stdio.h>
void main()
{
int max(int x,int y);
int a,b;
scanf("%d%d",&a,&b);
printf("%d\n",max(a,b));
}
int max(int x,int y)
{
return(x>y?x:y);
}
上述例子中定义了max函数,你最好把你的源码发来我给你看看哪里有错
你写这函数的目的是干啥啊?求你test()的一半?
如果是,那可改为
#include <stdio.h>
int test(int n);
main()
{
int a=100;
printf("%d",test(a));
}
int test(int n)
{
int m;
m=n/2;
return(m);
}
尽量别省略参数,忘了哪些情况可以省略了。。。
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯