Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- struct szulev{
- int ev1,ev2,ev3;
- };
- void main(){
- FILE *ft, *fb;
- struct szulev x;
- int cnt, max;
- fb=fopen("bintar.txt","wb");
- do{
- printf("1. szuletesi ev: ");scanf("%d",&x.ev1);
- if(x.ev1 != 0){
- printf("2. szuletesi ev: ");scanf("%d",&x.ev2);
- printf("3. szuletesi ev: ");scanf("%d",&x.ev3);
- printf("\n");
- fwrite(&x,sizeof(x),1,fb);
- }
- }while(x.ev1 != 0);
- fclose(fb);
- printf("\nBinaris adattar Szoveges adattar\n");
- printf("------------------------------------\n");
- fb=fopen("bintar.txt","rb");
- ft=fopen("txttar.txt","wt");
- while(cnt=fread(&x,sizeof(x),1,fb)==1){
- if(x.ev1<x.ev2 && x.ev1<x.ev3) max=x.ev1;
- if(x.ev2<x.ev1 && x.ev2<x.ev3) max=x.ev2;
- if(x.ev3<x.ev1 && x.ev3<x.ev2) max=x.ev3;
- fprintf(ft,"%d'n",max);
- printf(" %d %d %d %d\n",x.ev1,x.ev2,x.ev3,max);
- }
- fclose(fb);
- fclose(ft);
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement