Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<time.h>
- int main()
- {
- FILE *f;
- int niz[10],i,n,niz1[10];
- srand(time(NULL));
- if(fopen("fajl","wb+"))==NULL){
- fprintf(stderr,"GRESKA PRI OTVARANJU DATOTEKE");
- exit(1);
- };
- for(i=0;i<10;printf("%d\t%d\n",i,(niz[i++]=rand()%200-100)));
- fwrite(niz,sizeof(int),10,f);
- return 0;
- fseek(f,0,SEEK_SET);
- fread(niz1,sizeof(int),10,f);
- printf("procitano iz datoteke:\n");
- for(i=0;i<10; printf("%d\t%d\n",i,niz1[i++]));
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment