Hi,
I keep getting this error
cw_testca.c:52: error: expected ‘)’ before ‘[’ token
I have no idea what is the issue. I guess it's something to do with my function.
Code:
#include <stdio.h>
int i, j, num;
float x[10000], y[10000], xsum, ysum, xbar, ybar, xmax, ymax, xmin, ymin;
main()
{
FILE *inputfile;
char filename[33];
char text[11];
printf("Enter name of datafile: ");
scanf("%s",&filename);
if ( (inputfile = fopen(filename, "r")) == NULL)
{
printf("Error opening file\n");
}
else {
printf("File opened successfully.\n");
i = 0 ;
while(!feof(inputfile)) {
/* loop through and store the numbers into the array */
fscanf(inputfile,"%f %f", &x[i], &y[i]);
i++;
}
printf("Number of numbers read: %d\n\n", i);
printf("The numbers are:\n");
for(j=0 ; j<i ; j++) { /* now print them out 1 by 1 */
printf("%f %f\n" , x[j], y[j]);
}
minimum_xvalue(x[j]); /*determine and print minimum x value*/
fclose(inputfile);
return 0;
}
}
minimum_xvalue(x[j])
{ xmin = x[0];
for (j=1; j<num; j++)
{
if (x[j] < xmin)
xmin = x[j];
printf("Minimum value of x is %f\n" , xmin);
return 0;
}
}
My input file is a random set of x, y pairs:
3.456 1.001
2.394 2.398
2.345 2.3456
8.345 9.345
3.56 10.2344
5.234 0.002
4.209 3.590
1.2034 2.344
3.455 0.928
1.345 9.123
0.212 0.23