[Linker] error undefined reference to `meanCalc(int, int)'
#include %26lt;iostream%26gt;
#include %26lt;cmath%26gt;
#include %26lt;fstream%26gt;
using namespace std;
int meanCalc(int,int);
int main ()
{
int array[25];
int count = 0;
int mean;
ofstream fout;
ifstream fin;
fin.open("lab1.txt");
if(!fin)
{
cout%26lt;%26lt;"lab1.txt FAILED TO OPEN"%26lt;%26lt;endl;
cout%26lt;%26lt;"PLEASE CHECK THE FILE AND TRY AGAIN";
}
do {
fin%26gt;%26gt;array[count];
count++;
} while (fin);
count-=2;
mean = meanCalc (array[25],count);
cout%26lt;%26lt;mean;
for (int i=0;i%26lt;=count;++i)
{
cout%26lt;%26lt;array[i]%26lt;%26lt;endl;
}
system ("PAUSE");
return 0;
}
int meanCalc (int (array)[25], int count)
{
int x;
int mean;
for (int i=0;i%26lt;=count;++i)
{
x = array[i] + array[i++];
}
mean = x/count;
return (mean);
}
What am I doing wrong in this C++ program?
int meanCalc(int,int);
doesn't jibe with:
int meanCalc (int (array)[25], int count)
first takes two ints as input, second takes array of ints and an int. you need to reconcile that. i would modify this int meanCalc(int,int); accordingly.
Reply:i#include%26lt;iostrem.h%26gt;
#include %26lt;cmath.h%26gt;
#include %26lt;fstream.h%26gt;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment