I'm trying to create a program that would first read a list from a data file containing names of people and their sales and then calculate the amount of commission each person makes. I'm trying to get the program to print the information on the screen and then print the same info on a separate data file but currently the gcc compiler would kill the process.
DevC++ is giving me the following errors:Code:#include <stdio.h> int main(){ int k; char text[81], name[30], surname[30]; double sale, comission; FILE *Inf_1, *Outf_1; Inf_1 = fopen("Sales.dat", "r"); Outf_1 = fopen("Comiss.dat", "w"); if ((Inf_1 == NULL) || (Outf_1 == NULL)) { printf("Error opening the file\n"); exit(1); } while(fgets(text,81,Inf_1)!=NULL) { k++; if (k%2 !=) { sscanf(text, "%s %s", name, surname); else { sscanf(text, "%lf", &sale); if (sale <= 25000) { comission = sale * .06; } if (sale > 25000 && sale <= 50000) { comission = sale * .09; } if (sale > 50000 && sale <= 80000) { comission = sale * .12; } if (sale > 80000) { comission = sale * .14; } printf("\n%s %s\n", name,surname); printf("The comission of Mr/Ms %s is %f, based on the sale of %f\n", surname, comission, sale); fprintf(Outf_1, "The comission of Mr/Ms %s is %f, based on the sale of %f\n", surname, comission, sale); } } fclose(Inf_1); fclose(Outf_1); exit(0); } }
18 hw6.c
parse error before `)'
40 hw6.c
warning: parameter names (without types) in function declaration
40 hw6.c
warning: data definition has no type or storage class
41 hw6.c
warning: parameter names (without types) in function declaration
42 hw6.c
parse error before `0'
42 hw6.c
warning: data definition has no type or storage class
I am currently in the middle of solving the bracket issues (at this moment, not very good at formatting on a UNIX platform) but I'm not sure how to solve the data definition errors. Any input?



LinkBack URL
About LinkBacks


