Facebook
From Ryuujin, 9 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 567
  1.  
  2. bool SaveS(Student *Lista) //Zapisywanie studentow. Zwroci 1 w przypadku bledu Wywolanie SaveS(Lista);
  3. {
  4.     FILE *file = fopen("Students.hihihahaha","wb");
  5.  
  6.     if(!file)
  7.         return 1;
  8.  
  9.     while(Lista)
  10.     {
  11.         fwrite(Lista,sizeof(Student),1,file);
  12.         Lista = Lista->N;
  13.     }
  14.  
  15.     fclose(file);
  16.     return 0;
  17. }
  18.  
  19. bool SaveN(Napoj *Lista) //Zapisywanie Napojow. Zwroci 1 w przypadku bledu
  20. {
  21.     FILE *file = fopen("Drinks.hihihahaha","wb");
  22.  
  23.     if(!file)
  24.         return 1;
  25.  
  26.     while(Lista)
  27.     {
  28.         fwrite(Lista,sizeof(Napoj),1,file);
  29.         Lista = Lista->N;
  30.     }
  31.  
  32.     fclose(file);
  33.     return 0;
  34. }
  35.  
  36. Student *LoadS(Student *Lista) //Wczytywanie Studentow. Zwroci 0 w wypadku bledu. Wywolanie Lista = LoadS(Lista);
  37. {
  38.     FILE *file = fopen("Students.hihihahaha","rb");
  39.  
  40.     if(!file)
  41.         return 0;
  42.  
  43.     Student Buf;
  44.     while(fread(&Buf,sizeof(Student),1,file))
  45.     {
  46.         Lista = AddS(Lista,Buf);
  47.     }
  48.  
  49.     fclose(file);
  50.     return Lista;
  51. }
  52.  
  53. Napoj *LoadN(Napoj *Lista) //Wczytywanie Napoje. Zwroci 0 w wypadku bledu. Wywolanie Lista = LoadN(Lista);
  54. {
  55.     FILE *file = fopen("Drinks.hihihahaha","rb");
  56.  
  57.     if(!file)
  58.         return 0;
  59.  
  60.     Napoj Buf;
  61.     while(fread(&Buf,sizeof(Napoj),1,file))
  62.     {
  63.         Lista = AddN(Lista,Buf);
  64.     }
  65.  
  66.     fclose(file);
  67.     return Lista;
  68. }
  69.