Advertisement
andruhovski

ArrayFromFile_Bin

Sep 11th, 2013
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. #include "stdafx.h"
  2.  
  3. int _tmain(int argc, _TCHAR* argv[])
  4. {
  5.     int i;
  6.     long N;
  7.     FILE *f;
  8.    
  9.     fopen_s(&f,"massiv1.bin","rb");
  10.     if (f==NULL) {
  11.         printf("Error in file!");
  12.         return -1;
  13.     }
  14.     fseek(f,0,SEEK_END);
  15.     N=ftell(f);
  16.     fseek(f,0,SEEK_SET);
  17.     int *mas = (int *) malloc(N);
  18.     fread (mas, N, 1, f);
  19.     fclose(f);
  20.     printf("It's OK!\n");
  21.     for (i=0;i<N/(sizeof(int));i++)
  22.         printf("%4d",mas[i]);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement