Ouch, fail on my part. Thank you guys so much, it works now.
Code:
#include <stdio.h>
#include <stdlib.h>
#define FILENAME "Car.txt"
struct CarData
{
char Driver[6];
char Type[12];
int CarNumber;
char Colour[7];
};
int main(void)
{
FILE *Car = fopen(FILENAME, "r");
//FILE *Output = fopen("Output.txt", "w");
int i=0;
struct CarData Veh[5];
//Determining if file contains info
if(Car == NULL)
{
printf("File does not exist.\n");
system("PAUSE");
exit (1);
}
while ( i < 3 &&
fscanf(Car, "%s %s %d %s", Veh[i].Driver, Veh[i].Type, &Veh[i].CarNumber, Veh[i].Colour) == 4 )
{
i++;
}
for(i=0; i<3; i++)
{
printf("%s %s %d %s\n",Veh[i].Driver, Veh[i].Type,
Veh[i].CarNumber, Veh[i].Colour);
}
system("PAUSE");
return 0;
}