In AddSalesman(), why I can print out result in salesman.txt but cannot print out the result in sales.txt?Code:#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #define N 2 #define Q 4 typedef struct{ char ID[10], s_name[50], gender, IC[11], date[20]; double sales[Q], total_s; }SALES_OF_SALESMAN; SALES_OF_SALESMAN D1[N]; SALES_OF_SALESMAN NN; int AddSalesman(void); int main(void){ double total_s[S]={0}; int row=0, col=0, a=0; FILE * fptr, * fpt; fpt = fopen("Salesman.txt", "r"); fptr = fopen("Sales.txt", "w"); if(!fpt){ printf("Cannot open Salesman.txt!\n"); exit(-1); } while(!feof(fpt)) { fscanf(fpt, "%[^|]|%[^|]|%[^|]|%[^|]|%[^\n]\n", &D1[row].ID1, &D1[row].s_name, &D1[row].gender, &D1[row].IC, &D1[row].date); row++; } for(row=0; row < S; row++) { printf("Salesman's ID : %s\n", D[row].ID); printf("Salesman's name : %s\n", D[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[col]); while(D1[row].sales[col]<0){ printf("You enter incorrectly...Please enter again : "); scanf("%lf", &NN.sales[col]); } D1[row].total_s += D1[row].sales[col]; fprintf(fptr, "|%.2lf", D1[row].sales[col]); } fprintf(fptr,"\n"); } mainmenu(); fclose(fpt); fclose(fptr); return 0; int AddSalesman(void) { int row, col; FILE * fpt, * fptr; fpt = fopen("Salesman.txt", "a"); fptr = fopen("Sales.txt", "a"); if(!fpt){ printf("Cannot open Salesman.txt!\n"); exit(-1); } if(!fptr){ printf("Cannot open Sales.txt!\n"); exit(-1); } printf("-Please enter-\n"); printf("New Salesman's ID : "); scanf("%s", &NN.ID); fflush(stdin); printf("New Salesman's name : "); scanf("%[^\n]", &NN.s_name); fflush(stdin); printf("New Salesman's gender (F/M)? : "); scanf("%c", &NN.gender); while(NN.gender != 'M' && NN.gender != 'm' && NN.gender != 'F' && NN.gender != 'f'){ fflush(stdin); printf("You enter incorrectly...Please enter again : "); scanf("%c", &NN.gender); } NN.gender=toupper(NN.gender); printf("New Salesman's IC number (xxxxxx-xx-xxxx) : "); fflush(stdin); scanf("%s", &NN.IC); printf("New Salesman's date join : "); scanf("%s", &NN.date); fprintf(fpt, "%s|%s|%c|%s|%s\n",NN.ID, NN.s_name, NN.gender, NN.IC, NN.date); fclose(fpt); for(col=0; col < Q; col++) { printf("New Salesman's quanterly sales : "); scanf("%lf", &NN.sales[col]); while(NN.sales[col]<0){ printf("You enter incorrectly...Please enter again : "); scanf("%lf", &NN.sales[col]); } } fprintf(fptr, "%s", NN.ID); for(col=0; col < Q; col++) fprintf(fptr, "|.2lf", NN.sales[col]); fprintf(fptr, "\n"); fclose(fptr); system("pause"); return 0; } }