I have a customer record which i wish to modify so i wrote the following to modify it but each time i typed the name i want to modify it will not modify and prints not found!
void modify(){
char another='y',choice,name[25],flag='n';
long id;
do
{
//clrscr();
//rewind(fc);
printf("SEARCH BY NAME : PRESS 1 ");
fflush(stdin);
choice=getchar();
if(choice=='1')
{
printf("ENTER CUSTOMER NAME : ");
fflush(stdin);
gets(name);
while(fread(newcous,size,1,fc)==1)
{
if(strcmp(newcous->CName,name)==0)
{
news();
flag='y';
break;
}
}
}
if(flag=='n')
{
printf("CUSTOMER NOT FOUND............ !\n");
}
printf("DO YOU WANT TO MODIFY ANOTHER CUTOMER(Y/N)");
fflush(stdin);
}while(another=='Y');
another=getchar();
//fclose(fc);
//Addcostumer();
}
void news()
{
char another='y';
//clrscr();
fseek(fc,-size,SEEK_CUR);
printf("CUSTOMER'S NEW NAME:");
printf("CUSTOMER'S NEW ADDRESS:");
printf("CUSTOMER'S NEW Puhelin:");
fflush(stdin);
gets(newcous->CName);
fflush(stdin);
gets(newcous->Address);
fflush(stdin);
gets(newcous->Puhelin);
printf("UPDATE THE CUSTOMER RECORD (Y/N)");
fflush(stdin);
another=getchar();
if(another=='y'||another=='Y')
fwrite(newcous,sizeof(struct CustomerData),1,fc);
rewind(fc);
}