Advertisement
Khadija_Assem

Untitled

Dec 14th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. void Save(moves X){
  2. FILE *fb;
  3. out_parts total;
  4. total=OUT(X,0);
  5. fb=fopen("Game.txt","w");//W for write
  6. unsigned char i,j;
  7. for (i=0;i<8;i++){
  8. for (j='A';j<='H';j++)
  9. fprintf(fb,"%c",maze[i][j]);
  10. }
  11. for(i=0;i<total.N.N1;i++)
  12. fprintf(fb,"%c",total.Out01[i]);
  13. fprintf(fb,"&");
  14. for(i=0;i<total.N.N2;i++)
  15. fprintf(fb,"%c",total.Out02[i].name);
  16. fprintf(fb,"&");
  17. fprintf(fb,"%c",X.ID);
  18. fprintf(fb,"&");
  19. fclose(fb);
  20. }
  21. out_parts Load(){
  22. unsigned char i,j,Count1=0,Count2=0,flag=0,ID;
  23. out_parts total;
  24. FILE *fb;
  25. fb = fopen("Game.txt","r");
  26. while(!feof(fb)){
  27. if(!0){
  28. for(i=0;i<8;i++){
  29. for(j='A';j<'I';j++){
  30. fscanf(fb,"%c",&maze[i][j]);
  31. }
  32. }
  33. fscanf(fb,"&&");
  34. flag=1;
  35. }
  36. else{
  37. fscanf(fb,"%[^&]&%c",&total.Out01[Count1++]);
  38. fscanf(fb,"%[^&]&%c",&total.Out02[Count2++]);
  39. //fscanf(fb,"%c",ID);
  40. }
  41. }
  42. fclose(fb);
  43. return total;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement