Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Program in C first char* is filename int* is id double* amt char* desig int size

ID: 3825946 • Letter: P

Question

Program in C

first char* is filename

int* is id

double* amt

char* desig

int size

please help!!!!

bool load_data(char*, int *, double *,char *, int ): This function takes the input file name, integer, double and character pointers and the size as integer. It opens the input file. If unable to open it, returns false. Otherwise load the account information from the text file into the integer, double and character arrays and return true at the end. The first char pointer is the string holding the name of the file to open, int * is the account ID array, double * is the amount array, the second char * is the designation array and the last int is the size or the number of records. Use fscanf or other library functions to read in the data.

Explanation / Answer

Hi, Please find my implementation.

Please let me know in case of any issue.

bool load_data(char *file, int *id, double *amt,char *desig, int n){

   int i = 0;

   FILE * fp(file, "r");

   // error check in opening file
   if(fp == NULL){
       return false;
   }

   // trading designation, id and amt in each ineration
   while(i < n){
       fscanf(fp, "%s%d%lf", &desig[i], &id[i], &amt[i]);
       i++;
   }

   fclose(fp); // closing file

   return true;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote