My problem is that I cannot get the digfilter to call from main correctly. I know that it needs the pointers, but I don't know if the ones I used are correct. I also am not sure if my cout statement in main for printing the final data to the screen is correct. Any input is greatly appreciated. I'm trying to study for a test and I need to be able to make these types of programs work correctly. The code follows. Thanks guys/gals.
Code:
#include <cstdlib>
#include <iostream>
#include <fstream>
using namespace std;
void getXvalues(int *numpoints, double x[])
{
cout << "Please enter the number of points: ";
cin >> *numpoints;
for (int i = 0; i < *numpoints; i++)
{
cout << "Please Enter a Point: ";
cin >> x[i];
}
}
void digfilter(int numpoints, double *x, double *y, double *z)
{
y[0] = z[0] = x[0];
for (int i = 1; i < numpoints; i++)
{
y[i] = (x[i]+ x[i])/2 > 1;
z[i] = (.5*(x[i] + z[i-1]));
}
}
int main(int argc, char *argv[])
{
double input[50];
int numpts;
getXvalues(&numpts, input);
double *outputx = new double[numpts];
double *outputy = new double[numpts];
double *outputz = new double[numpts];
digfilter(numpts, outputx, outputy, outputz);
ofstream outpt("Output.txt");
for (int i = 0; i < numpts; i++)
{
outpt << outputx[i] << outputy[i] << outputz[i]<< endl;
cout << " X = " << outputx[i] << " Y = " << outputy[i] << " Z = " << outputz[i];
}
outpt.close();
delete outputx, outputy, outputz;
system("PAUSE");
return EXIT_SUCCESS;
}