gcc -Wall polygon.cCode:#include <stdio.h> #define MAX_ARRAY_SIZE 20 int get_corners(FILE* fp,double x_array[],double y_array[],MAX_ARRAY_SIZE); void output_corners(FILE* foutput,double x_array[],double y_array[],int *actual_size); double polygon_area(double x_array[],double y_array[],int*actual_size); int main(int argc,char*argv[]) { int actual_size; double x_array[MAX_ARRAY_SIZE]; double y_array[MAX_ARRAY_SIZE]; int i=0; int j=0; FILE *fp; //opens a file and reads it. Then calls get_corners function which then extracts data from it fp =fopen(argv[1],"r"); get_corners(&fp,x_array,y_array,MAX_ARRAY_SIZE); FILE *foutput; //opens a file and writes to it. Using output parameters foutput=fopen(argv[2],"w"); output_corners(&foutput,x_array,y_array,&actual_size); polygon_area(x_array,y_array,&actual_size); //calculates polygon area return 0; }//main int get_corners(FILE *fp,double x_array[],double y_array[],MAX_ARRAY_SIZE) { FILE *fp; fp =fopen(argv[1],"r"); while(fscanf(fp,"%lf%lf",&x_array[i],&y_array[j])!=EOF) { i++; j++; } return *actual_size=j; } void output_corners(FILE*foutput,double x_array[],double y_array[],int *actual_size) { } double polygon_area(double x_array[],double y_array[],int *actual_size) { return 0;
polygon.c:5:60: error: expected declaration specifiers or '...' before numeric constant
polygon.c: In function 'main':
polygon.c:19:1: warning: implicit declaration of function 'get_corners' [-Wimplicit-function-declaration]
polygon.c:23:1: warning: passing argument 1 of 'output_corners' from incompatible pointer type [enabled by default]
polygon.c:6:6: note: expected 'struct FILE *' but argument is of type 'struct FILE **'
polygon.c: At top level:
polygon.c:30:60: error: expected declaration specifiers or '...' before numeric constant
Can someone tell me why my macro MAX_ARRAY_SIZE is showing up as an error? (Line 5)
Also whats wrong with Lines 6,19,23?
Thanks so much guys



LinkBack URL
About LinkBacks


