Advertisement
Guest User

Untitled

a guest
May 26th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. printf("Dwste ISBN tou epi8umhtou bibliou pros daneismo:\n");
  2. gets(n);
  3. fp=fopen("books","r");
  4. while (( !feof(fp) ) && (found!=0) )
  5. {
  6. fread(&b,sizeof(b),1,fp);
  7. if (!feof(fp) && strcmp(n,b.isbn)== 0 )
  8. {
  9. found=0;
  10. printf("to biblio uparxei sth biblio8hkh:\n");
  11. printf("%s %s %d \n" ,b.isbn,b.titlos,b.antitupa);
  12.  
  13. copies+=b.antitupa;
  14. printf("copies= %d\n",copies);
  15.  
  16. fp2=fopen("daneismoi","a+");
  17.  
  18. if (fp2==NULL)
  19. {
  20. printf("file not found!\n");
  21. break;
  22. }
  23. fseek(fp2, 0, SEEK_END); // seek to end of file
  24. int size = ftell(fp2);
  25. if (size==0)
  26. {
  27. printf("Empty file!\n");
  28. fclose(fp2);
  29. break;
  30. }
  31. fseek(fp2, 0, SEEK_SET);
  32. while ( !feof(fp2) )
  33. {
  34. fread(&d,sizeof(d),1,fp2);
  35. while (strcmp(n,d.isbn)== 0 )
  36. { copies--;
  37. }
  38. }
  39. fclose(fp2);
  40.  
  41. printf("diathesima antitupa= %d\n", copies);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement