【发布时间】:2015-11-20 18:47:58
【问题描述】:
为什么我们在第二行的int add(int,int) 语句之后使用分号。
#include<stdio.h>
int add(int,int);
int main()
{
int a,b,c;
scanf("%d %d",&a,&b);
c=add(a,b);
printf("The sum of the 2 numbers is %d",c);
return 0;
}
int add(int x,int y)
{
int sum;
sum=x+y;
return sum;
}
【问题讨论】:
-
为了和函数实现区分开来。
-
因为否则编译器会期望您在大括号中提供函数的定义 (
{ }) -
因为这是指定语言的方式。
标签: c function declaration function-prototypes