Here's the part that I updated, everything else remained the same.
Code:
void get_input (address_record* addresses[], int* nr_addresses)
{
int k;
char file_name[1000];
FILE* pAddressFile;
address_record* pA;
printf("Input file: ");
scanf("%999[^\n]", file_name);
pAddressFile = fopen(file_name, "r");
if(pAddressFile == NULL)
{
fprintf(stderr, "Error trying to open %s to read file.\n", file_name);
abort();
}
for(k = 0; k < MAX_RECORDS; k++)
{
addresses[k] = malloc(sizeof(address_record));
}
}
So from here, I would use fgets inside (or outside?) of the loop to get each line from the file and from there use sscanf to get each of the parts of the line and store each of them in the struct members? Also, what do you mean by tokense and tokenising? I don't remember my teacher talking about this.
Edit*
One more question. My program has to be able to read 200 records. So would I need to multiply the sizeof in malloc by 200 or is it already taken care of by the address[k] assignment?