0

Hi,
now i have work on it for a long time it is working but,
when it can not find the item any how it will print item not found + item found , i have no idea what is wrong any help welcome,
thanks

....
...
..


    if( (strcmp(s->Aname,nAname)==0) && (strcmp(s->Oname,nOname)==0) )

		flag=1;
		if(flag==0)
		{
			printf("*********************************************************************\n");
			printf("*******************  can not find item   ********************\n");
			printf("*********************************************************************\n\n\n");

    
		}

   rewind(fp);

   fflush(stdin);

   while( fread(s,recsize,1,fp) == 1)

   {
    if( (strcmp(s->Aname,nAname) != 0) || (strcmp(s->Oname,nOname) != 0) )

      fwrite(s,recsize,1,ft);
   }

   if(flag == 1)

	printf("*********************************************************************\n");
	printf("*******************  item found  ********************\n");
	printf("*********************************************************************\n");

	fclose(fp);
	fclose(ft);
	remove("autotiedot.bin");
	rename("temp.dat","autotiedot.bin");
	fp=fopen("autotiedot.bin","rb++");
   


	fclose(fp);
3
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by Ancient Dragon
0

Hello,
I saw ur code but not getting what u exactly want to do. I am not getting the variables if possible send the whole code so that i will help u

0

your code is missing parentheses. Without parentheses, only the first line after the if statement belongs to the condition, all other lines will be executed regardless of the if condition.

if(flag == 1)
  {
	printf("*********************************************************************\n");
	printf("*******************  item found  ********************\n");
	printf("*********************************************************************\n");
  }
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.