Advertisement
JCLC

Untitled

Jun 12th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(){
  5.     int *x, y = 0;
  6.  
  7.     x = (int *) malloc(sizeof(int)*4);
  8.  
  9.     if(x == NULL){
  10.         printf("Nao foi possivel alocar memoria.");
  11.         exit(0);
  12.     }
  13.  
  14.     for(y = 0; y < 4; y++){
  15.         x[y] = y+3;
  16.     }
  17.    
  18.     FILE *bin;
  19.  
  20.     bin = fopen("arquivo.bin", "rb");
  21.  
  22.     if(bin == NULL){
  23.         printf("Nao foi possivel abrir o arquivo.");
  24.         exit(0);
  25.     }
  26.  
  27.     fread(x, 16, 1, bin);
  28.    
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement