Advertisement
Voldemord

Untitled

Jan 3rd, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define N 10
  4.  
  5. struct careOfPlant{
  6. char plant_name[25];
  7. short int light_intens;
  8. short int water_demand;
  9. int fertilization_interval;
  10. char fertilization_time[25];
  11. short int temperature_from;
  12. short int temperature_to;
  13. };
  14.  
  15. typedef struct careOfPlant plant_care;
  16.  
  17. int CountTypeOfPlants = 0;
  18.  
  19. void addDefinitionOfPlants( plant_care *tab )
  20. {
  21. printf("Podaj nazwe rosliny: ");
  22. fflush(stdin);
  23. gets(tab->plant_name);
  24.  
  25. printf("Podaj intensywnosc oswietlenia: ");
  26. fflush(stdin);
  27. scanf("%hd",&tab->light_intens);
  28.  
  29. printf("Podaj ilosc podlewania: ");
  30. fflush(stdin);
  31. scanf("%hd",&tab->water_demand);
  32.  
  33. printf("Podaj czestotliwosc nawozenia: ");
  34. fflush(stdin);
  35. scanf("%d",&tab->fertilization_interval);
  36.  
  37. printf("Podaj czas nawozenia: ");
  38. fflush(stdin);
  39. gets(tab->fertilization_time);
  40.  
  41. printf("Podaj temperature od: ");
  42. fflush(stdin);
  43. scanf("%hd",&tab->temperature_from);
  44.  
  45. printf("Podaj temperature do: ");
  46. fflush(stdin);
  47. scanf("%hd",&tab->temperature_to);
  48.  
  49. CountTypeOfPlants++;
  50. }
  51.  
  52. void showAllTypeOfPlants(plant_care *tab)
  53. {
  54. int i;
  55. for(i = 0; i < CountTypeOfPlants; i++)
  56. {
  57. puts(tab->plant_name);
  58. printf("",);
  59. }
  60. }
  61.  
  62. int main(void)
  63. {
  64. int i;
  65. plant_care *p = NULL;
  66. p = malloc(N * sizeof(*p));
  67. do{
  68. i=0;
  69. printf("1-Dodaj rosline\n");
  70. printf("2-Wyswietl wszystkie rosliny\n");
  71. printf("3-Wyswietl rosline\n");
  72. printf("5-Wyjdz\n");
  73. printf("Wybierz opcje: ");
  74. scanf("%d",&i);
  75. switch(i)
  76. {
  77. case 1:
  78. addDefinitionOfPlants(p);
  79. break;
  80. case 2:
  81.  
  82. break;
  83. case 3:
  84.  
  85. break;
  86. case 5:
  87.  
  88. break;
  89. default:
  90. printf("Podano zly argument\n");
  91. break;
  92. }
  93. fflush(stdin);
  94. }while(i!=5);
  95. return 0;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement