Expand|Select|Wrap|Line Numbers
- #include <stdio.h>
- #include <stdlib.h>
- double calculusx[1000];
- double calculusy[1000];
- double integral0i[1000];
- double integrali999[1000];
- double derivative[1000];
- int i=0;
- double Area0i(double[], double[]);
- double Areai999(double[], double[]);
- double Slope(double[],double[]);
- double Slope(double x[], double y[])
- {
- double result;
- result = (((x[i] - x[i-1])/(x[i+1] - x[i-1]))*((y[i] - y[i-1])/(x[i] - x[i-1]))) + (((x[i+1] - x[i])/(x[i+1] - x[i-1]))*((y[i+1] - y[i-1])/(x[i] - x[i-1])));
- return result;
- }
- double Area0i(double x[], double y[])
- {
- double result;
- int j;
- for (j=0; j<=i; j++)
- {
- result += ((x[i]-x[i-1])*((y[i]+y[i+1])/2));
- }
- return result;
- }
- double Areai999(double x[], double y[])
- {
- double result;
- int j;
- for (j=i; j<1000; j++)
- {
- result += ((x[i]-x[i-1])*((y[i]+y[i+1])/2));
- }
- return result;
- }
- int main(int argc, char *argv[])
- {
- int z;
- FILE* fp;
- FILE* fp2;
- if (argc<2)
- {
- return EXIT_FAILURE;
- }
- fp = fopen(argv[1],"r");
- if (argv[i] == NULL || fp == NULL)
- {
- printf("Incorrect filename.\n");
- return EXIT_FAILURE;
- }
- fp2 = fopen("program2output.txt", "w");
- for (z=0; z<1000; z++)
- {
- fscanf(fp, "%lf %lf", &calculusx[z], &calculusy[z]);
- }
- for (i=0; i<1000; i++)
- {
- integral0i[i] = Area0i(calculusx[i], calculusy[i]);
- integrali999[i] = Areai999(calculusx[i], calculusy[i]);
- derivative[i] = Slope(calculusx[i], calculusy[i]);
- fprintf(fp2, "%5.3lf\t%5.3lf\t%5.3lf\t%5.3lf\t%5.3lf\n", calculusx[i],calculusy[i], integral0i[i], integrali999[i], derivative[i]);
- }
- fclose(fp);
- fclose(fp2);
- return EXIT_SUCCESS;
- }
The program is meant to read a list of inputs from a file, store then in two arrays I have named calculusx and calculusy, perform some math on them, and then spit the outputs into another file.
The problem is, whenever I try to compile, the three functions I call in main (integral0i, integrali999, and derivative) give me errors that the arguments in the functions are of an incompatible type. I swear that I've defined the arrays as doubles, the functions return a double, and that I am putting in doubles as my argument. Can somebody please help me with this, it is driving me insane.