Please help me, I am trying to search a string from a structure which is in a text file, here is the code:
void update()
{
char ask;
fpt= fopen("records.dat", "rb+");
long int recsize= sizeof(customer);
printf("recsize: %d", recsize);
ask= 'Y';
while(ask== 'Y')
{
printf("\nEnter the Product Id to modify: ");
rewind(fpt);
while(fgets(customer.product_ID, 79, fpt)!=NULL)
{
puts(pdct_ID);
if(strcmp(pdct_ID, customer.product_ID)== 0)
{
printf("Comparison Successful");
break;
}
else
printf("No match found");
}
printf("\nModify another record(Y/N)");
fflush(stdin);
ask= getche();
}
}
here customer is the structure variable, product_Id is the structure member, record.dat is my text file