数组干形参

数组作形参
麻烦各位大哥,大姐帮忙看看这个程序有什么问题
#include <stdio.h>
void main()
{
int a[10]={1,2,3,4,5,6,7,8,9,10};
test(a);

putchar('\n');
}

void test(int b[10])
{
int i=0;
for (;i<10;i++)
{
printf("%d\n",b[i]);
}

}
怎么我的会有
E:\C\1\1.c(5) : warning C4013: 'test' undefined; assuming extern returning int
E:\C\1\1.c(11) : error C2371: 'test' : redefinition; different basic types
Error executing cl.exe.错误的,是不是新建出了问题?

------解决方案--------------------
那是因为你在进入主函数的时候test函数还没有进入作用域。有两个方法:第一:在main函数前申明函数void test(int b[10]);
第二:把你的test函数定义在main函数之前。
------解决方案--------------------
C/C++ code

#include <stdio.h>
void test(int b[10]);

void main()
{
int a[10]={1,2,3,4,5,6,7,8,9,10};
test(a);

putchar('\n');
}

void test(int b[10])
{
int i=0;
for (;i<10;i++)
{
printf("%d\n",b[i]);
}

}

------解决方案--------------------
楼上说的基本都对,就是test函数没有声明。
该处的解决方法有两个:1)把函数在main函数之前声明;2)把test函数的定义写在main函数之前

另外,一般用一维数组做形参时,不需要指定大小,并且指定了大小也没用,只是当成了一个指针,但如果需要使用数组的大小,通常需要当成参数一样传递进去。
1)void test(int b[],int lenth) //lenth是数组的长度
2)void test(int *b,int lenth) //这两种是一样的


另外,二维数组作为形参的时候,一般会这样使用下面两种方式:
1)
void test(int b[][4],int lenth) //必须指定二维大小
{

}

2)
void test(int (*b)[4],int lenth)
{}

int main()
{
int a[3][4];
test(a,3); //如果子函数中需要使用一维的大小,则最好使用传递的方式得到
}