无法将参数“1”的“char*”转换为“int*”到“int median(int*, int)” array2 = m
cannot convert ‘char*’ to ‘int*’ for argument ‘1’ to ‘int median(int*, int)’ array2 = median(array,size);
我的问题是我在标题中指定的: test_median.cpp:
在函数 'int main()' 中: test_median.cpp:26:27: 错误: 无法转换 "char*"到"int*"表示参数"1"到"int median(int*, int)"
array2 = median(array,size);
所以这是我的代码。这是测试器代码;
#include <iostream>
#include <cmath>
#include "IpFunctions.h"
using namespace std;
int main()
{
int size;
cout<< "size gir" <<endl;
cin >> size;
int i;
char array[size];
cout<< "değerleri gir"<<endl;
for (i=0;i<size;i=i+1)
{
cin >> array[i];
}
char array2[size];
array2 = median(array,size);
cout<<"array2 = "<<array2<<endl;
return 0;
}
这是中值函数代码:
#include <iostream>
#include <cmath>
using namespace std;
int median(char array[], int size)
{
int i = 0;
int m,n;
while (i<size)
{
if (array[i]>array[i+1])
{
m = array[i]; n = array[i+1];
array[i] = n; array[i+1] = m;
i=i+1;
}
else
{
i=i+1;
}
}
return *array;
}
最后是"IpFunctions.h"标头:
// this is just a headerfile that you add your Image processing functions' prototypes.
// when testing your functions with a main function
// main needs a prototype of the function
//Image medianfiltering(Image &inimg, const int size );
int median(int array[],int size);
// when you type a function add the header here !!!
// such as
// Image negative(Image &inimg);
所以我只想创建一个函数来获取数组的中位数并返回该数组。
在
标题中
int median(int array[],int size);
在.cpp文件中
int median(char array[], int size)
您的主要内容正在尝试调用第一个(这是它唯一知道的)
相关文章:
- 为什么在全局范围内使用"extern int a"似乎不行?
- int(c) 和 c-'0' 之间的区别。C++
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 为什么野牛仍在使用"int yylex(void)",却找不到"int yylex(YYS
- 有符号的int和int-有没有一种方法可以在C++中区分它们
- 请解释这句话(cout<<1+int((a<b)^((b-a)&1) )<<endl
- 是否可以从int转换为enum类类型
- 不能在初始值设定项列表中将非常量表达式从类型 'int' 缩小到'unsigned long long'
- 向量 <int> a {N, 0} 和 int arr a[N] = {0} 的时间复杂度有什么区别
- 'short int'持有的值溢出,但"自动"不会溢出?
- 如何在C++中将一个无符号的 int 转换为两个无符号的短裤?
- 调用'begin(int [n])'没有匹配函数
- 没有显式声明的int[]中的foreach
- 在c++中访问int到类对象的映射时出错
- 为什么我无法更改"set<set>"循环中的值<int>
- 长 长 int 不要 长 int 好
- C++程序在循环后给出奇怪的int值
- 如何计算数据类型的范围,例如int
- 如果"new int"返回"int*",那么为什么"new int[n]"不返回"int**"?
- 无法将参数“1”的“char*”转换为“int*”到“int median(int*, int)” array2 = m