1

I want to read the contents of a file and sort them. The input file has a single column and records three attributes so it's like:

11579704
Man
Leo
11579704
Man
Joey
11579704
Man
Franny
11579704
Auto
Lucy
18919736
Man
Jose

I've set up 3 arrays and I want to populate each array with one of the criteria i.e. an array for all Car plates.

FILE* filePtr = fopen("vehicle.txt", "r");

while (!feof(filePtr)) /* while not End of File */
{
fscanf(filePtr, "%s%s%s", InputFileArray1[i], InputFileArray2[i], InputFileArray3[i]);
i++; /* increment counter */

} /*end while */

Should the above read from the file and populate the arrays or is it rubbish???

Yunnosch
  • 26,130
  • 9
  • 42
  • 54

0 Answers0