In: Computer Science
code in C
Step 1
For example: chrLetter = fgetc( pfilInput );
Step 2
typedef struct
{
long lngRecordID;
char strFirstName[ 50 ];
char strMiddleName[ 50 ];
char strLastName[ 50 ];
char strStreet[ 100 ];
char strCity[ 50 ];
char strState[ 50 ];
char strZipCode[ 50 ];
} udtAddressType;
Step 3
Step 4
------------------------------------------------------------
Customer #1
First Name: Luke
Middle Name:
Last Name: Skywalker
Address: 123 Elm Street
City: Corusant
State: Ohio
Zip Code: 45202
------------------------------------------------------------
Customer #2
…
Extra Credit
Extra Extra Credit
#include<stdio.h>
#define MAX 100
typedef struct
{
    long lngRecordID;
    char strFirstName[ 50 ];
    char strMiddleName[ 50 ];
    char strLastName[ 50 ];
    char strStreet[ 100 ];
    char strCity[ 50 ];
    char strState[ 50 ];
    char strZipCode[ 50 ];
}udtAddressType;
//to load the addresses from file in array
int load_address(udtAddressType arr[])
{
   FILE *file;
   file = fopen("addresses.txt","r");
   if(file==NULL)
       printf("Error");
   int i=0,j=0;
   char c;
   while(getc(file) != EOF)
   {  
       fseek( file, -1, SEEK_CUR );
      
fscanf(file,"%d",&arr[i].lngRecordID);  
       c = getc(file);
       c = getc(file);
       j=0;
       while(c != ' ' )
       {
          
arr[i].strFirstName[j] = c;
           j++;
           c =
getc(file);
       }
       c = getc(file);
       j=0;
       while(c != ' ' )
       {
          
arr[i].strMiddleName[j] = c;
           j++;
           c =
getc(file);
       }
       c = getc(file);
       j=0;
       while(c != ',' )
       {
          
arr[i].strLastName[j] = c;
           j++;
           c =
getc(file);
       }
       c = getc(file);
       j=0;
       while(c != ',' )
       {
          
arr[i].strStreet[j] = c;
           j++;
           c =
getc(file);
       }
       c = getc(file);
       j=0;
       while(c != ',' )
       {
          
arr[i].strCity[j] = c;
           j++;
           c =
getc(file);
       }
       c = getc(file);
       j=0;
       while(c != ',' )
       {
          
arr[i].strState[j] = c;
           j++;
           c =
getc(file);
       }
       c = getc(file);
       j=0;
       while(c != '\n' )
       {
          
arr[i].strZipCode[j] = c;
           j++;
           c =
getc(file);
       }
       i++;
   }
   return i;
}
//to print the array
void printAddress(udtAddressType arr[],int size)
{
   int i;
   for( i=0;i<size;i++)
   {
      
printf("-----------------------------------------------------------------------\n");
       printf("Customer #%d\n",i+1);
       printf("\t\tFirst Name :
%s\n",arr[i].strFirstName);
       printf("\t\tMiddle Name :
%s\n",arr[i].strMiddleName);
       printf("\t\tLast Name :  
%s\n",arr[i].strLastName);
       printf("\t\tAddress
:     %s\n",arr[i].strStreet);
       printf("\t\tCity
:       
%s\n",arr[i].strCity);
       printf("\t\tState
:       %s\n",arr[i].strState);
       printf("\t\tZip Code
:    %s\n\n",arr[i].strZipCode);
   }
}
int main()
{
   udtAddressType arr[MAX];
   int size = load_address(arr);
   printAddress(arr,size);
   return 0 ;
}
//Output

