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);
	 }

I saw those links and i try to us fgets() instead of gets that i use but still, is still printing not found whenever i type the name i wanted to modify.

Then display the name you type in EXACTLY as the variable sees it. Is it character by character an identical match? Are there characters you don't normally see as characters in one of the names (like a trailing SPACE, TAB, CR, LF)?

This article has been dead for over six months. Start a new discussion instead.