Advertisement
Guest User

timmm

a guest
Sep 24th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <io.h>
  4. #include <fcntl.h>
  5. #include <sys/stat.h>
  6. #include <sys/types.h>
  7.  
  8. int main()
  9. {
  10.     int t[106]={0};
  11.     int i=0;
  12.     int z=0;
  13.     int db=0;
  14.  
  15.     int f1;
  16.     int f2;
  17.  
  18.     for(i=147;i>41; i--)
  19.     {
  20.         t[z]=i;
  21.         z++;
  22.     }
  23.  
  24.     f1=open("adat.txt", O_CREAT | O_RDWR,
  25.             S_IREAD | S_IWRITE);
  26.  
  27.     write(f1,t,sizeof(t));
  28.     close (f1);
  29.  
  30.     f1=open("adat.txt",O_RDONLY);
  31.     f2=open ("adat2.dat",O_CREAT | O_RDWR,
  32.              S_IREAD | S_IWRITE);
  33.     while (read(f1,&i,sizeof(int)))
  34.     {
  35.         if((i%2)==0)
  36.         {
  37.             db++;
  38.             printf("tomb elemei: %d\n",i);
  39.             write(f2,&db,sizeof(int));  //talán innen hiányzik valami :D
  40.  
  41.         }
  42.     }
  43.  
  44.     printf("db: %d\n",db);
  45.     close (f1);
  46.     close (f2);
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement