Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define S 2
#define SS 4
typedef struct{
char ID[10], s_name[50];
double sales[1][SS];
}SALES_OF_SALESMAN;
SALES_OF_SALESMAN D1[S];
typedef struct{
char gender[5], IC[11], date[20];
}SALESMAN_DETAILS;
SALESMAN_DETAILS D2[S];
int mainmenu(void);
int submenu(void);
int AddSalesman(void);
int QtrReport(void);
int SalesComm(double total_s[N], int row, int col, double sales[S][SS], char s_name[S][50]);
int main(void)
{
double total_s[S]={0}, total=0, average;
int row=0, col=0, a=0;
FILE * fptr, * fpt;
fpt = fopen("Salesman.txt", "r");
fptr = fopen("Sales.txt", "w");
while(!feof(fpt))
{
fscanf(fpt, "%[^|]|%[^|]|%[^|]|%[^|]|%[^\n]\n", &D1[row].ID, &D1[row].s_name, &D2[row].gender, &D2[row].IC, &D2[row].date);
row++;
}
for(row=0; row < N; row++)
{
printf("Salesman's ID : %s\n", D1[row].ID);
printf("Salesman's name : %s\n", D1[row].s_name);
fprintf(fptr, "%s|", D1[row].ID);
fflush(stdin);
for(col=0; col < Q; col++)
{
printf("Salesman's quanterly sales : ");
scanf("%lf", &D1[row].sales[0][col]);
total_s[row] += D1[row].sales[0][col];
total += D1[row].sales[0][col];
fprintf(fptr, "%.2lf|", D1[row].sales[0][col]);
}
fprintf(fptr,"\n");
}
average = total / S;
mainmenu();
fclose(fpt);
fclose(fptr);
return 0;
}
int mainmenu(void)
{
int c1;
printf("\n");
printf("Sales Processing System\n");
printf("-----------------------\n\n");
printf("1. Add Salesman Records\n2. Reports Generation\n3. Modify Salesman Records\n4.Delete Salesman Records\n\n0. Exit\n\n");
printf("Your choice: ");
scanf("%d", &c1);
while(c1!=0 && c1!=1 && c1!=2){
printf("Error! Please enter correctly! : ");
scanf("%d", &c1);
}
if(c1==0)
{
printf("You are exiting this program...Bye bye.\n");
}
else if (c1==1)
{
AddSalesman();
}
else if(c1==2)
{
submenu();
}
return 0;
}
int submenu(double total_s[S], int row, int col, double total, double average)
{
int c2;
printf("\n");
printf("Report Generation\n");
printf("-----------------\n\n");
printf("1. View Quarterly Sales Report\n2. View Individual Salesman Commission\n\n0. Return to Main Menu\n\n");
printf("Your choice: ");
scanf("%d", &c2);
while(c2!=0 && c2!=1 && c2!=2){
printf("Error! Please enter correctly! : ");
scanf("%d", &c2);
}
if(c2==0)
{
mainmenu();
}
if(c2==1)
{
QtrReport();
}
else if(c2==2)
{
SalesComm(total_s, row, col);
}
return 0;
}
int AddSalesman(void)
{
printf("addsalesman");
}
int QtrReport(int row, int col, double total_s[S], double total, double average)
{
double hs;
char hI[10];
for(row=0; row < N; row++)
{
printf("%-11s %-11s ", D1[row].ID, D1[row].s_name);
for(col=0; col < 4; col++)
{
printf("%-11.2lf ", D1[row].sales[1][col]);
}
printf("%11.2lf\n", total_s[row]);
}
printf(" Total : %14.2lf\n", total);
printf("Average sales : RM%.2lf\n", average);
hs=total_s[0];
for(row = 0; row < N; row++)
{
for(col = 0; col < Q; col++)
{
if(total_s[row] > hs)
{
hs=total_s[row];
}
}
printf("Highest sales : RM%.2lf achieved by", hs);
for(row = 0; row < N; row++)
{
if(hs==total_s[row])
{
if(row==0)
strcpy(hI, "S0001");
if(row==1)
strcpy(hI, "S0002");
}
}
printf("\n");
}
return 0;
}
int SalesComm(double total_s[S], int row, int col)
{
double commission;
int s_ID;
printf("1.%s %s\n2.%s %s", &D1[0].ID, &D1[0].s_name, &D1[1].ID, &D1[1].s_name);
printf("Which Salesman do you want to view? Please enter his/her ID : ");
scanf("%d", &s_ID);
while(s_ID!=1 && s_ID!=2){
printf("Error! Please enter correctly! : ");
scanf("%d", &s_ID);
}
if(s_ID==1)
{
row=0;
}
else if(s_ID==2)
{
row=1;
}
if(total_s[row]<50000)
{
commission = total_s[row]*0.03;
}
else if(total_s[row]<100000)
{
commission = total_s[row]*0.05;
}
else
{
commission = total_s[row]*0.08;
}
printf("Individual Salesman Commission for 2011\n");
printf("---------------------------------------\n\n");
printf("Salesman ID : %d", D1[row].ID);
printf("Name : %s", D1[row].s_name);
printf("Total Sales : %.2lf", total_s[row]);
printf("Commission : %.2lf", commission);
return 0;
} |
'SalesComm' : too few arguments for call...how do I solve this error?