diff --git a/cv2/program.c b/cv2/program.c index fed4574..618d992 100644 --- a/cv2/program.c +++ b/cv2/program.c @@ -5,7 +5,7 @@ #define LINESIZE 100 struct pizza { - char price[LINESIZE]; + float price; char name[LINESIZE]; }; @@ -33,7 +33,8 @@ int main(){ if (strlen(vstup) == 0) { break; } - strcpy(menu[count].price, vstup); + float cislo = strtof(vstup, NULL); + menu[count].price = cislo; } else { break; } @@ -42,8 +43,7 @@ int main(){ qsort (menu, count, sizeof(struct pizza), compare_pizza); for(int i = 0; i < count;i++){ printf("%s\n", menu[i].name); - float number = strtof(menu[i].price, NULL); - printf("%f\n", number); + printf("%f\n", menu[i].price); } return 0; } \ No newline at end of file