Advertisement
Kocyk

wczyt

Jan 10th, 2019
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5.  
  6. typedef struct
  7. {
  8. char imie[20];
  9. char nazwisko[20];
  10. int godziny;
  11. int stawka;
  12. int premia;
  13. }osoba;
  14. void wczytywaniedanych(osoba *osoba)
  15. {
  16.  
  17. printf("Podaj imie i nazwisko osoby\n");
  18. scanf("%s", &osoba->imie );
  19. scanf("%s", &osoba->nazwisko);
  20. printf("Podaj stawke godzinowa\n");
  21. scanf("%d", &osoba->godziny);
  22. printf("Podaj liczbe godzin\n");
  23. scanf("%d", &osoba->godziny);
  24. printf("Podaj premie\n");
  25. scanf("%d", &osoba->premia);
  26. // printf("%d",osoba->godziny);
  27.  
  28. }
  29. void wyswietlanie(osoba osoba)
  30. {
  31. printf("%s %s stawka: %d",osoba.imie,osoba.nazwisko,osoba.godziny);
  32. }
  33. float obliczanko(osoba janusz)
  34. {
  35. float y;
  36. y=janusz.godziny*janusz.stawka *(1+janusz.premia /100.);
  37. printf("%f",y);
  38. return y;
  39. }
  40. int main()
  41. {
  42. osoba osoby[3];
  43. int rozmiar=sizeof(osoba);
  44. FILE *f;
  45. f=fopen("firma.txt", "rb");
  46. int i=0;
  47. while(fread(&osoby[i],rozmiar,1,f)==1)
  48. {
  49. wyswietlanie(osoby[i]);
  50. i++;
  51. }
  52.  
  53.  
  54.  
  55. //wyswietlanie(osoba1);
  56. //printf("Osoba ma otrzymac %.2f ", obliczanko(osoba1));
  57.  
  58. return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement