This commit is contained in:
mr314ot 2025-10-09 19:13:54 +02:00
parent 11bc008f12
commit 19ef0dec39

View File

@ -31,14 +31,12 @@ int read_pizza(struct pizza *item) {
}
line2[strcspn(line2, "\n")] = '\0';
float value;
if (sscanf(line2, "%f", &value) != 1) {
return 0;
}
strncpy(item->name, line1, LINESIZE - 1);
item->name[LINESIZE - 1] = '\0';
item->price = value;
return 1;
}
@ -68,14 +66,13 @@ int main() {
struct pizza list[MAXITEMS];
int count = 0;
//nacitanie listka
while (count < MAXITEMS && read_pizza(&list[count])){
count++;
}
//ukoncit ak ziadne polozky
if (count <= 0) {
return 0;
//citanie listka
while (count < MAXITEMS){
struct pizza tmp;
if (!read_pizza(&tmp)){
break;
}
list[count++] = tmp;
}
//triedenie
@ -84,7 +81,7 @@ int main() {
//vypis listka
for (int i = 0; i < count; i++){
printf("%s\n", list[i].name);
printf("%s\n", list[i].price);
printf("%.6f\n", list[i].price);
}
return 0;