0

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

Edited by mike_2000_17: Fixed formatting

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by __avd
0

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]

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.