Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int main()
  6. {
  7.     FILE *fp;
  8.     fp = fopen("liczby3.dat", "w + b");
  9.     srand(time(NULL));
  10.     int i, x, buf;
  11.     for(i = 0; i < 10; i++)
  12.     {
  13.         x = rand() % 20;
  14.         fwrite(&x, sizeof(int), 1, fp);
  15.     }
  16.  
  17.     while(fread(&buf, sizeof(int), 1, fp))
  18.         printf("%d, ", buf);
  19.  
  20.     FILE *fp1;
  21.     fp1 = fopen("kopia.dat", "w + b");
  22.     fseek(fp,0,0);
  23.  
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement