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

Welcome debolin,
Show us your code which writes struct data into a datafile.
Use code tags. Source code must be surrounded with code tags.
for example,

[code=c] ... statements ...

[/code]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.