How can I pass the lastId variable value to AddSalesMan() function?Code:#include <stdio.h> #include <stdlib.h> #include <string.h> // number of salesman #define SIZE 100 // salesman_type structure definition typedef struct{ int ID; char id_txt[6], name[50]; double hor_total; }salesman_type; // end structure salesman_type // define salesman_type variable salesman_type salesman[SIZE]; // function prototype int nextId(); int sale_menu(); void AddSalesMan(); // function to generate id // currentId and isReset are parameters int nextId(int currentId, int isReset) { // initializes elements to 0 first time function is called static int lastId = 0; // if isReset is x; assign x to lastId; return lastId with adding 1 if (isReset) { lastId = currentId; } return ++lastId; } // sales processing system menu function int sale_menu() { int menu; printf("Sales Processing System\n"); printf("-----------------------\n\n"); printf("1. Add Salesman Records\n"); printf("2. Reports Generation\n"); printf("3. Modify Salesman Records\n"); printf("4. Delete Salesman Records\n\n"); printf("0. Exit\n"); printf("Your choice: "); scanf("%d", &menu); return menu; printf("\n"); } // function to add salesman void AddSalesMan() { FILE *inSales; int a, b; double sale[SIZE][4]; if ( (inSales = fopen("sales.txt","a")) == NULL) printf("Cannot open sales.txt file."); else { for(a=0; a<SIZE; a++) { fprintf(inSales,"S%04d|",salesman[a].ID); //printf("Name: "); //scanf(" %[^\n]", salesman[a].name); for (b=0; b<4; b++) { printf("Quarter %d: ",b+1); scanf(" %lf", &sale[a][b]); fprintf(inSales,"%lf|",sale[a][b]); } fputc('\n',inSales); printf("\n"); } } fclose(inSales); } // function main begins program execution void main() { // nextid.txt file pointer FILE *idPtr; // variable declaration int a, b, c = 0, last; // counter int getMenu = 0, getReport = 0; // menu selector double ver_total = 0, max = 0; int id = 0, lastId, resetId = 0; // fopen files the file; exits program if file cannot be opened if ( (idPtr = fopen("nextid.txt","r") ) == NULL) { printf("Cannot open nextid.txt file\n"); system("pause"); exit(-1); } // end if else { // read lastId from file fscanf(idPtr,"%d",&lastId); // Generate new id from previous salesman ID if the salesman is one or more // lastId and restId are arguments nextId(lastId, resetId); } // end else // fclose close the file fclose(idPtr); // Initialize salesman id from nextId function and salesman horizontal total value to zero for(a=0; a<SIZE; a++) { salesman[a].hor_total = 0; } // call and assign sale_menu function to getMenu getMenu = sale_menu(); printf("\n"); // Execute command based on user input switch(getMenu) { // call AddSalesMan function case 1: AddSalesMan(); break; // call and assign report_menu to getReport case 2: break; } // end switch system("pause"); }