Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <io.h>
- #include <fcntl.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- int main()
- {
- int t[106]={0};
- int i=0;
- int z=0;
- int db=0;
- int f1;
- int f2;
- for(i=147;i>41; i--)
- {
- t[z]=i;
- z++;
- }
- f1=open("adat.txt", O_CREAT | O_RDWR,
- S_IREAD | S_IWRITE);
- write(f1,t,sizeof(t));
- close (f1);
- f1=open("adat.txt",O_RDONLY);
- f2=open ("adat2.dat",O_CREAT | O_RDWR,
- S_IREAD | S_IWRITE);
- while (read(f1,&i,sizeof(int)))
- {
- if((i%2)==0)
- {
- db++;
- printf("tomb elemei: %d\n",i);
- write(f2,&db,sizeof(int)); //talán innen hiányzik valami :D
- }
- }
- printf("db: %d\n",db);
- close (f1);
- close (f2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement