Advertisement
Guest User

fosbloksz

a guest
Jun 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. struct szulev{
  5.     int ev1,ev2,ev3;
  6. };
  7. void main(){
  8.     FILE *ft, *fb;
  9.     struct szulev x;
  10.     int cnt, max;
  11.     fb=fopen("bintar.txt","wb");
  12.     do{
  13.         printf("1. szuletesi ev: ");scanf("%d",&x.ev1);
  14.         if(x.ev1 != 0){
  15.             printf("2. szuletesi ev: ");scanf("%d",&x.ev2);
  16.             printf("3. szuletesi ev: ");scanf("%d",&x.ev3);
  17.             printf("\n");
  18.             fwrite(&x,sizeof(x),1,fb);
  19.         }
  20.     }while(x.ev1 != 0);
  21.     fclose(fb);
  22.     printf("\nBinaris adattar   Szoveges adattar\n");
  23.     printf("------------------------------------\n");
  24.     fb=fopen("bintar.txt","rb");
  25.     ft=fopen("txttar.txt","wt");
  26.     while(cnt=fread(&x,sizeof(x),1,fb)==1){
  27.         if(x.ev1<x.ev2 && x.ev1<x.ev3) max=x.ev1;
  28.         if(x.ev2<x.ev1 && x.ev2<x.ev3) max=x.ev2;
  29.         if(x.ev3<x.ev1 && x.ev3<x.ev2) max=x.ev3;
  30.         fprintf(ft,"%d'n",max);
  31.         printf(" %d %d %d       %d\n",x.ev1,x.ev2,x.ev3,max);
  32.     }
  33.     fclose(fb);
  34.     fclose(ft);
  35.     getch();
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement