0

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);
	 }
2
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by WaltP
0

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.

0

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 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.