daily pastebin goal
47%
SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Autor:
  3. Grupa:
  4. Album:
  5. Data:
  6. Kod:
  7. Forma: Pracownia specjalistyczna
  8. IDE: Microsoft Visual Studio 2008
  9. */
  10.  
  11.  
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #pragma warning (disable:4996)
  15.  
  16. float Zamiana(float far)
  17. {
  18.     return (5/9)*(far-32);
  19. }
  20.  
  21. int main(int argc, char *argv[]) {
  22.    
  23.    
  24.    
  25.     FILE *  fpBin = fopen("sensor.dat","rb");
  26.     if (fpBin == NULL)
  27.     {
  28.         printf("Blad otwarcia pliku sensor.dat\n");
  29.         return 0;
  30.     }
  31.     FILE *  fpSensor = fopen("sensor.txt","w");
  32.     if (fpSensor == NULL)
  33.     {
  34.         printf("Blad otwarcia pliku sensor.txt\n");
  35.         return 0;
  36.     }
  37.    
  38.     int nr_czujnika;
  39.     float far;
  40.     int bledy=0;
  41.    
  42.     while(!feof(fpBin))
  43.     {
  44.         fread(&nr_czujnika,sizeof(int),1,fpBin);
  45.         if(nr_czujnika!=0)
  46.         {
  47.             fread(&far,sizeof(float),1,fpBin);
  48.             printf("[%d] -> [ %.2f F] -> [ %.ff C]\n",nr_czujnika,far,Zamiana(far));
  49.             fprintf(fpSensor,"[%d] -> [ %.2f F] -> [ %.ff C]\n",nr_czujnika,far,Zamiana(far)); 
  50.         }
  51.         else
  52.         {
  53.             bledy++;
  54.         }
  55.        
  56.        
  57.     }
  58.    
  59.     printf("Ilosc bledow %d", bledy);
  60.    
  61.    
  62.    
  63.     return 0;
  64. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top