如何在C语言中定义一个函数?

为什么我怎么定义函数都不正确呢?
总是说我 表达语法错误在main函数中
我用的编译器是WIN-TC
解释详细点
#include <stdio.h>
void test(int );
main()
{int a=100;

printf("%d",test(a));
getch();
}
void test(int )
{int n,m;
m=n/2;
return(m)

}
这是我写的,错误很多
高手指点下,别见笑,本人刚学不久

第1个回答  2008-11-19
先声明,再定义,声明必须在第一次调用前.
如果在第一次使用之前定义则可将声明与定义一块进行
类型 函数名(参数表)
第2个回答  2008-11-19
/*sample*/
#include <stdio.h>
void test(void);
int main()
{
test();
return 0;
}
void test(void)
{
printf("you have called the test()!");
}
第3个回答  2008-11-19
类型 函数名(参数表)
第4个回答  2008-11-19
是不是没有在 main 前声明函数
相似回答