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

Hello, please give me the code for this project in C Programming. Thank you. int

ID: 3827437 • Letter: H

Question

Hello, please give me the code for this project in C Programming. Thank you.

int readCustomersInfo(char *filename, CustInfo arr[]) {

int n = 0; // ... return n;

}

This function should open and read the given input file which contains information about all customers. It should store each customer's data in an element of the given array arr, and return the number of customers it read from the file. The general format of the input file is below:

SSN                            First Name Last Name
----------------------------------------------------------------
xxx-xx-3192                Farhad Akbar
xxx-xx-0721                Bassam Awad Alanazi
xxx-xx-9210                Roger Cungtha Biak
xxx-xx-7226                Christian C. Collier
xxx-xx-0802                Tanner Durnil
xxx-xx-1155                Melissa Gudeman
xxx-xx-7530                Daniel Patrick Kobold Jr
xxx-xx-8162                Travis Lee Leondis
xxx-xx-0011                Cleopatrio Soares Neto
xxx-xx-5533                Daniel Biaklian Sang
xxx-xx-1100                Bryant Bernard
xxx-xx-8123                Joaquin John Garcia
xxx-xx-3128                Jacob Austin Shebesh
xxx-xx-9011                D'Artagnan S. Engle
xxx-xx-1234                You Zhou
xxx-xx-4321                Joi Ashlyn Officer

Explanation / Answer

#include <stdio.h>

struct CustInfo
{
   char * ssn;
   char * fname;
   char * lname;
};

int readCustomersInfo(char *filename, struct CustInfo arr[]);
int main(){
   struct CustInfo arr[10];
   int n = readCustomersInfo("input.txt",arr);
   printf(" %d record added",n);
   return 0;
}

int readCustomersInfo(char *filename,struct CustInfo arr[]) {
   FILE* file = fopen (filename, "r");
   if(file == NULL)
       return 1;
   int count = 0;
   while (!feof (file))
   {
   char* ssn;
   char* fname;
   char* lname;
       fscanf(file,"%s %s %s ",ssn,fname,lname);
       printf("%s %s %s ",ssn,fname,lname);
       arr->ssn = ssn;
       arr->fname = fname;
       arr->lname = lname;
       count++;
   }
   return count;
}