Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <string.h>
- #include <io.h>
- void fgv();
- void fgv1();
- void fgv2();
- void fgv3();
- int main()
- {
- fgv();
- fgv1();
- fgv2();
- fgv3();
- return 0;
- }
- void fgv()
- {
- int hnd,c;
- hnd=open("adat.txt",O_RDONLY);
- while(1)
- {
- c=read(hnd,&c,sizeof(c));
- if(c==-1) return 1;
- else return 0;
- printf("%c",c);
- }
- close(hnd);
- }
- void fgv1()
- {
- int hnd, r;
- hnd=open("adat.txt",O_RDONLY);
- r=tell(hnd);
- printf("meret = %i bajt\n\n",r);
- close(hnd);
- }
- void fgv2()
- {
- int hnd,i=0,j=0,t[100];
- hnd=open("adat.txt",O_CREAT|O_RDWR,S_IREAD|S_IWRITE);
- while(i<100)
- {
- if(j%3==0)
- {
- t[i]=j;
- i++;
- }
- j++;
- }
- for(i=0;i<100;i++)
- {
- write(hnd,&t[i],sizeof(t[i]));
- printf("%i\t",t[i]);
- }
- close(hnd);
- }
- void fgv3()
- {
- int hnd,i=0,r,j=0,t[100];
- hnd=open("adat.txt",O_CREAT|O_RDWR,S_IREAD|S_IWRITE);
- while(i<100)
- {
- if(j%3==0)
- {
- t[i]=j;
- i++;
- }
- j++;
- }
- hnd=open("adat.txt",O_RDONLY);
- while(1)
- {
- r=read(hnd,&t[i],sizeof(t[i]));
- if(r>0) break;
- close(hnd);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement