diff --git a/du2/program.c b/du2/program.c index fa9aafb..50430fc 100644 --- a/du2/program.c +++ b/du2/program.c @@ -30,11 +30,12 @@ int read_pizza(struct pizza *item) { return 0; } 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'; return 1; @@ -75,13 +76,12 @@ int main() { list[count++] = tmp; } - //triedenie - sort_pizzas(list, count); - - //vypis listka - for (int i = 0; i < count; i++){ - printf("%s\n", list[i].name); - printf("%.6f\n", list[i].price); + if (count > 0) { + sort_pizzas(list, count); + for (int i = 0; i < count; i++){ + printf("%s\n", list[i].name); + printf("%.6f\n", list[i].price); + } } return 0;