Chinaunix
标题:
请教一个程序在vc++里面编译不能通过的问题
[打印本页]
作者:
瞬间思路
时间:
2004-04-16 22:59
标题:
请教一个程序在vc++里面编译不能通过的问题
为什么我的这段代码在vc++里 编译会有这种错误呢?是什么原因呢?
代码如下
#include "stdio.h"
void cour_ave (int a, int b,float score[])
{
int course ,stud;
float total1,aver1;
for (course = 0; course < b; course++)
{
total1 = 0 ;
for ( stud = 0;stud < a;stud++)
total1 = total1 + score[stud*b+course];
aver1 = total1 / a;
printf ("average of course %d is :%6.2f\n",course,aver1);
}
return;
}
void stud_ave (int a, int b,float score[])
{
int course ,stud;
float total2,aver2;
printf("\n"
;
for (stud = 0;stud < a ;stud++)
{
total2 = 0;
for (course = 0;course < b;course ++)
total2 = total2 + score[stud * b + course ];
aver2 = total2 / b;
printf ("average of student %d is %6.2f\n",stud,aver2);
}
return;
}
#define a 4
#define b 3
void main ()
{
void cour_ave (int x,int y,float score[]);
void stud_ave(int x,int y,float score[]);
float score[a]
={{89,78,56},{88,99,100},{72,80,61},{60,70,75}};
cour_ave(a,b,score);
stud_ave(a,b,score);
return;
}
编译提示信息如下:
ompiling...
stand.cpp
D:\Program Files\Microsoft Visual Studio\MyProjects\zhou\stand.cpp(42) : error C2664: 'cour_ave' : cannot convert parameter 3 from 'float [4][3]' to 'float []'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\Program Files\Microsoft Visual Studio\MyProjects\zhou\stand.cpp(43) : error C2664: 'stud_ave' : cannot convert parameter 3 from 'float [4][3]' to 'float []'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
stand.obj - 2 error(s), 0 warning(s)
请帮我想想
作者:
whyglinux
时间:
2004-04-16 23:18
标题:
请教一个程序在vc++里面编译不能通过的问题
cour_ave(a,b,
score[0]
);
stud_ave(a,b,
score[0]
);
或者
cour_ave(a,b,
&score[0][0]
);
stud_ave(a,b,
&score[0][0]
);
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2