Advertisement
Romanius

Untitled

Apr 9th, 2012
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.63 KB | None | 0 0
  1. new ___arrayNull___[1] = { 0 };
  2. #define _(ARRAY)NULL ___arrayNull___
  3.  
  4. static stock arrayToFile(filename[], _array[], size = sizeof _array)
  5. {
  6.     size *= 4;
  7.  
  8.     new File:tmpFile = fopen(filename, io_write);
  9.    
  10.     for(new i = 0; i < size; i++)
  11.         fputchar(tmpFile, _array{i}, false);
  12.        
  13.     fclose(tmpFile);
  14. }
  15.  
  16. static stock fileToArray(filename[], _array[], size = sizeof _array)
  17. {
  18.     size *= 4;
  19.  
  20.     new File:tmpFile = fopen(filename, io_read);
  21.    
  22.     memcpy(_array, _(ARRAY)NULL, 0, size); // Заполняем массив нулями
  23.    
  24.     for(new i = 0; i < size; i++)
  25.         _array{i} = fgetchar(tmpFile, _array{i}, false);
  26.        
  27.     fclose(tmpFile);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement