Advertisement
Aseron

BeforeChaos

Oct 23rd, 2017
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.29 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.  
  7.     // 1c.______________________________________
  8.  
  9.     float pi = 3.1415926;
  10.     char* s = "kerulete";
  11.     double m = 6.23768e+24;
  12.  
  13.     printf("%.2f %12s %.3e", pi, s, m);
  14.  
  15.     printf("\n");
  16.  
  17.     // 2c.______________________________________
  18.  
  19.     int u1;
  20.     double v1,v2;
  21.  
  22.     FILE* input;
  23.     input = fopen("in.txt","r");
  24.  
  25.     if(input == NULL){
  26.         perror(input);
  27.     }
  28.  
  29.     fscanf(input,"%d %lf %lf", &u1, &v1, &v2 );
  30.  
  31.     fclose(input);
  32.  
  33.     printf("%d %lf %lf\n", u1, v1, v2);
  34.  
  35.     // 3c.______________________________________
  36.  
  37.     int error = 666;
  38.  
  39.     fprintf(stderr,"A hibakod: %8X\n", error);
  40.  
  41.     // 4c.______________________________________
  42.  
  43.     double kiA[6] = {1.1,1.2,1.3,1.4,1.5,1.6};
  44.     double beA[6];
  45.  
  46.     FILE* inputB;
  47.     inputB = fopen("a.bin","wb");
  48.  
  49.     if(inputB == NULL){
  50.         perror(inputB);
  51.     }
  52.  
  53.     fwrite(kiA, 6*sizeof(double), 1, inputB);
  54.  
  55.     fflush(inputB);
  56.  
  57.     inputB = fopen("a.bin","rb");
  58.  
  59.     fread(beA, 6*sizeof(double), 1, inputB);
  60.  
  61.     fclose(inputB);
  62.  
  63.     int i;
  64.  
  65.     for(i = 0; i < (int) (sizeof(beA) / sizeof(*beA)); i++){
  66.         printf("%.1lf ", beA[i]);
  67.     }
  68.     // i < 6 is boven eleg persze, csak igy "ujrafelhasznalhatobb"
  69.     return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement