Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define N 10
- struct careOfPlant{
- char plant_name[25];
- short int light_intens;
- short int water_demand;
- int fertilization_interval;
- char fertilization_time[25];
- short int temperature_from;
- short int temperature_to;
- };
- typedef struct careOfPlant plant_care;
- int CountTypeOfPlants = 0;
- void addDefinitionOfPlants( plant_care *tab )
- {
- printf("Podaj nazwe rosliny: ");
- fflush(stdin);
- gets(tab->plant_name);
- printf("Podaj intensywnosc oswietlenia: ");
- fflush(stdin);
- scanf("%hd",&tab->light_intens);
- printf("Podaj ilosc podlewania: ");
- fflush(stdin);
- scanf("%hd",&tab->water_demand);
- printf("Podaj czestotliwosc nawozenia: ");
- fflush(stdin);
- scanf("%d",&tab->fertilization_interval);
- printf("Podaj czas nawozenia: ");
- fflush(stdin);
- gets(tab->fertilization_time);
- printf("Podaj temperature od: ");
- fflush(stdin);
- scanf("%hd",&tab->temperature_from);
- printf("Podaj temperature do: ");
- fflush(stdin);
- scanf("%hd",&tab->temperature_to);
- CountTypeOfPlants++;
- }
- void showAllTypeOfPlants(plant_care *tab)
- {
- int i;
- for(i = 0; i < CountTypeOfPlants; i++)
- {
- puts(tab->plant_name);
- printf("",);
- }
- }
- int main(void)
- {
- int i;
- plant_care *p = NULL;
- p = malloc(N * sizeof(*p));
- do{
- i=0;
- printf("1-Dodaj rosline\n");
- printf("2-Wyswietl wszystkie rosliny\n");
- printf("3-Wyswietl rosline\n");
- printf("5-Wyjdz\n");
- printf("Wybierz opcje: ");
- scanf("%d",&i);
- switch(i)
- {
- case 1:
- addDefinitionOfPlants(p);
- break;
- case 2:
- break;
- case 3:
- break;
- case 5:
- break;
- default:
- printf("Podano zly argument\n");
- break;
- }
- fflush(stdin);
- }while(i!=5);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement