Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.  
  7.    FILE * f = fopen("prova.txt","w");
  8.  
  9.    int a = 5;
  10.  
  11.     a = fwrite(&a, sizeof(int), 1, f);
  12.  
  13.     if (a !=1 ){
  14.         perror("write");   
  15.         exit(EXIT_FAILURE);
  16.  
  17.     }
  18.  
  19.     char *ciao="ciao!";
  20.  
  21.     a = fwrite(ciao, sizeof(char), 5 , f);
  22.  
  23.     if (a !=5 ){
  24.         perror("write");   
  25.         exit(EXIT_FAILURE);
  26.  
  27.     }
  28.  
  29.    a = 7;
  30.  
  31.     a = fwrite(&a, sizeof(int), 1, f);
  32.  
  33.     if (a !=1 ){
  34.         perror("write");   
  35.         exit(EXIT_FAILURE);
  36.  
  37.     }
  38.  
  39.     ciao="settete";
  40.  
  41.     a = fwrite(ciao, sizeof(char), 7 , f);
  42.  
  43.     if (a !=7 ){
  44.         perror("write");   
  45.         exit(EXIT_FAILURE);
  46.  
  47.     }
  48.  
  49.    a = 3;
  50.  
  51.     a = fwrite(&a, sizeof(int), 1, f);
  52.  
  53.     if (a !=1 ){
  54.         perror("write");   
  55.         exit(EXIT_FAILURE);
  56.  
  57.     }
  58.  
  59.     ciao="bam";
  60.  
  61.     a = fwrite(ciao, sizeof(char), 3 , f);
  62.  
  63.     if (a !=3 ){
  64.         perror("write");   
  65.         exit(EXIT_FAILURE);
  66.  
  67.     }
  68.  
  69.     exit(EXIT_SUCCESS);
  70.  
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement