Hi
I have a function where I scan from a '/' (slash) delimited text file. here is an exteract
Ford/BigTruck/b671asd/fix doors/doorsrus/01-01-04/23328/2000.00/
Chevy/4L Van/B235QWQ/paint rear/colouyrs/02-08-09/32433/2001.00/
HiFlier/5Di/B568ASS/fix rear bumper/automtix/01-08-09/323/425.00
Ford/BigTruck/b671asd/remove dents/fifi/12-03-11/12345/300.00/
I want to extract lines from the text file base on the license registration, which is the third field. so this is my code:
repair_reports()
{
FILE *zfile;
int Found=0;
zfile= fopen ("repair.dat","r");
printf("\n Enter Registration Number: ");
gets(registration);
while (!feof(zfile))
{
fscanf(zfile,"%19[^/]/%[^/]/%[^/]/[^/]/%[^/]/%[^/][^/]/d/",vehicle_name,model,registration_number,short_des cription,garage_mechanic,repair_date,invoice,&Amt) ;
if (feof(zfile))
break;
}
//string that compares to registration name
if (strcasecmp(registration,registration_number)== 0)
Found = 1;
if (Found)
{
printf("Vehicle_name: %s\n", vehicle_name);
printf("model: %s\n", model);
printf("Registration Number: %s\n", registration_number);
fclose(zfile);
system("pause");
}
else
printf(" No Repairs Found ");
system("pause");
}
}
The problem is: the comparison fails since it does not pick the right field for registration_number