all.
After reading up on segmentation faults, I still can't figure out just where this one's coming from. I know that it's coming from this specific function; everything else in my driver program works.
Worth noting is that all of the styles are of the enumerated data type, StyleT.
The function being called:
openList(&list, "List.txt");
The function's definition:
void openList(VehicleListT *list, char *infilename)
{
FILE *infile;
int i = 0;
char styleString[20];
newList(list);
if((infile = fopen(infilename, "r")) == NULL)
{
fprintf(stderr, "ERROR: Cannot open source file!\n");
exit(1);
}
fscanf(infile, "%s\n", list->vehicles[i].vin);
while(!feof(infile))
{
fscanf(infile, "%i\n", list->vehicles[i].year);
fscanf(infile, "%lf\n", list->vehicles[i].price);
fscanf(infile, "%s\n", list->vehicles[i].make);
fscanf(infile, "%s\n", styleString);
if((strcmp(styleString, "TWO_DOOR")) == 0)
{
list->vehicles[i].style = TWO_DOOR;
}
if((strcmp(styleString, "FOUR_DOOR")) == 0)
{
list->vehicles[i].style = FOUR_DOOR;
}
if((strcmp(styleString, "CONVERTIBLE")) == 0)
{
list->vehicles[i].style = CONVERTIBLE;
}
if((strcmp(styleString, "TRUCK")) == 0)
{
list->vehicles[i].style = TRUCK;
}
if((strcmp(styleString, "SUV")) == 0)
{
list->vehicles[i].style = SUV;
}
fscanf(infile, "%s\n", list->vehicles[i].color);
fscanf(infile, "%s\n", list->vehicles[i].vin);
i++;
list->count++;
}
fclose(infile);
return;
}
newList?