From f314b8479f673298e63a1bf8a7fb7bbfa9ef72be Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 1 Oct 2024 15:22:17 +0200 Subject: [PATCH] Initializacia --- cv2/program.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 cv2/program.c diff --git a/cv2/program.c b/cv2/program.c new file mode 100644 index 0000000..93d2060 --- /dev/null +++ b/cv2/program.c @@ -0,0 +1,64 @@ +#include +#include +#include +#include + +#define LINE_SIZE 100 +#define LIST_SIZE 100 + +struct pizza{ + char name[LINE_SIZE]; + float price; +} + +int read_pizza_list(struct pizza* list){ + char buffer[LINE_SIZE] + while(fgets(buffer, LINE_SIZT, stdin) == 0){ + + } +} + +int read_item(struct pizza *item) { + static int currentIndex = 0; + + if (currentIndex >= sizeof(menu) / sizeof(menu[0])) { + return 0; + } + + memcpy(item, &menu[currentIndex], sizeof(struct pizza)); + currentIndex++; + + return 1; +} + + +int main(){ + struct pizza vacerajsia = {.name = "Vajcova pizza", .price = 0.2}; + printf("Pizza: %s, cena: %f/n", vacerajsia.name, vacerajsia.price -0.1); + + // Prechadzajte vsetky miesta jedalneho listka + int counter = 0; + for (int i=0; i< LIST_SIZE; i++){ + struct pizza item; + memset(&item,0,sizeof(struct pizza)); + // Nacitajte polozku do pomocnej premennej + // Na nacitanie pouzite vlastny kod + int r = read_item(&item); + if (r){ + // Ak sa nacitanie podarilo, skopirujte polozku do pola + memcpy(&listok[i],&item,sizeof(struct pizza)); + // Spocitame uspesne nacitane polozky + counter += 1; + } + else{ + // Ak sa nacitanie nepodarilo, nasli sme poslednu polozku + // Prerusim nacitanie + break; + } + } + // Na konci budemem mat nacitany jedalny listok + // V premennej counter je pocet uspesne nacitanych poloziek + return 0; +} + +