【发布时间】:2014-07-31 16:53:23
【问题描述】:
#include <stdio.h>
void copy_arr(double, double, int);
void copy_ptr(double, double *, int);
int main()
{
double source[5]={1.1,2.2,3.3,4.4,5.5};
double target1[5]={0.0};
double target2[5]={0.0};
copy_arr(source, target1, 5);
copy_ptr(source, target2, 5);
return 0;
}
void copy_arr(double source[5],double target1[5],int arraysize)
{
int count=0;
puts("....copying using array notation.....");
for(count=0;count<arraysize;count++)
{
target1[count]=source[count];
printf("target 1 is : %d\t", target1[count]);
}
}
double copy_ptr(double source[5],double *target2,int arraysize)
{
int count=0;
puts("....copying using pointer notation.....");
for(count=0;count<arraysize;count++)
{
*(target2+count)=source[count];
printf("target 2 is : %f\t", *target2);
}
}
错误::
错误:“copy_arr”的参数 1 的类型不兼容 copy_arr(source, target1, 5);
错误:“copy_arr”的参数 2 的类型不兼容 copy_arr(source, target1, 5);
错误:“copy_ptr”的参数 1 的类型不兼容 copy_ptr(source, target2, 5);
错误:“copy_arr”的类型冲突 void copy_arr(double source[5],double target1[5],int arraysize)
错误:“copy_ptr”的类型冲突 void copy_ptr(double source[5],double *target2,int arraysize)
我在网上查了资料,但大部分都是关于原型的。我的在这里,但我仍然收到此错误!是什么原因?
【问题讨论】:
-
您有问题吗?
-
我想问题是:你能帮我解决错误吗? :)
-
...主要是关于原型。 检查原型。例如,
double与double[5]的类型不同。 -
谢谢@John C 现在只有我知道他们不一样哈哈!
-
我的意思不是进攻性的,只是认为轻轻一推就能让你重新定位。你几乎总是可以为它的原型复制一个函数的签名行,因为名称被忽略了。
标签: c prototype conflict incompatibility