From 62a4fabcf9e3cadea13295c0d31e7c1047591852 Mon Sep 17 00:00:00 2001 From: vj586da Date: Thu, 7 Oct 2021 20:18:08 +0200 Subject: [PATCH] v3 --- cv1/program.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 99fba0f..627d3ab 100755 --- a/cv1/program.c +++ b/cv1/program.c @@ -21,7 +21,7 @@ int main(){ char sign[] = {'o','i','z','e','a','s','b','t','b','q'}; char secret[]={'0','1','2','3','4','5','6','7','8','9'}; - char input_search[20]; + char input_search[50]; //initialize input_search struct item menu[NUMBER_OF_MEALS]; struct backup_item backup_menu[NUMBER_OF_MEALS]; @@ -34,7 +34,7 @@ int main(){ //} - printf("Zadaj hladanu surovinu: "); + printf("Zadaj hladanu surovinu:\n"); fgets (input_search, 20, stdin); printf("Zadaj jedalny listok:\n"); @@ -43,19 +43,22 @@ int main(){ //initialize temp int meal_counter = 0; //load menu + char* ptr = NULL; while(1){ - fgets (menu[meal_counter].name, 20, stdin); - if(menu[meal_counter].name[0] == '\n'){ + ptr = fgets (menu[meal_counter].name, 20, stdin); + if(ptr == NULL){ + break; + } + if(menu[meal_counter].name[0] == '\n'){ break; } - fgets (temp, 10, stdin); + fgets (temp, 20, stdin); menu[meal_counter].price = strtof(temp, NULL); meal_counter++; } - //make copy of menu for (int i = 0 ; i < meal_counter; i++){ strcpy(backup_menu[i].name, menu[i].name);