daily pastebin goal
46%
SHARE
TWEET

Untitled

a guest Jan 21st, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void read_back(const char *filename)
  2. {
  3.     FILE* pFile;
  4.     long lSize=100;
  5.     char* buffer;
  6.     buffer = (char*)malloc(sizeof(char)*lSize);
  7.     pFile = fopen(filename, "rb");
  8.     if (pFile == NULL) { fputs("File error", stderr); exit(1); }
  9.  
  10.     // copy the file into the buffer:
  11.     size_t result = fread(buffer, 1, lSize, pFile);
  12.     if (result != lSize) { fputs("Reading error", stderr); exit(3); }
  13.        fclose(pFile);  
  14. }
  15.  
  16. int main()
  17. {
  18.     const char *fname[2];
  19.     fname[1] = "C:\1_data.bin";
  20.     fname[2] = "C:\2_data.bin";
  21.     fname[3] = "C:\3_data.bin";
  22.  
  23.     for (int i = 0; i < 2; ++i)
  24.     {
  25.         read_back(fname[i]);
  26.     }
  27.     return 0;
  28. }
  29.    
  30. const char *fname[3];
  31.     fname[0] = "C:\1_data.bin";
  32.     fname[1] = "C:\2_data.bin";
  33.     fname[2] = "C:\3_data.bin";
  34.    
  35. if (result != lSize) { fputs("Reading error", stderr); exit(3); }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top