My problem is as I specify in the title: test_median.cpp:
In function ‘int main()’: test_median.cpp:26:27: error: cannot convert ‘char*’ to ‘int*’ for argument ‘1’ to ‘int median(int*, int)’
array2 = median(array,size);
So here is my code. This is the tester code;
#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;
}
This is the median function code:
#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;
}
And finally "IpFunctions.h" header:
// 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);
So I just wanted to make a function to take the median of an array and return that array.
in the header
in the .cpp file
your main is trying to invoke the first one (its the only one it knows about)