du2 - 7
This commit is contained in:
parent
8010ecc6cb
commit
4eaf1ab6fb
@ -2,7 +2,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define LINESIZE 200
|
#define LINESIZE 256
|
||||||
#define MAXITEMS 100
|
#define MAXITEMS 100
|
||||||
|
|
||||||
// struktura pre polozku jed. listka
|
// struktura pre polozku jed. listka
|
||||||
@ -17,7 +17,7 @@ int read_pizza(struct pizza *item) {
|
|||||||
char line2[LINESIZE];
|
char line2[LINESIZE];
|
||||||
|
|
||||||
//nazov
|
//nazov
|
||||||
if (fgets(line1, sizeof(line1), stdin) == NULL) {
|
if (!fgets(line1, sizeof(line1), stdin)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
line1[strcspn(line1, "\n")] = '\0';
|
line1[strcspn(line1, "\n")] = '\0';
|
||||||
@ -26,7 +26,7 @@ int read_pizza(struct pizza *item) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//cena
|
//cena
|
||||||
if (fgets(line2, sizeof(line2), stdin) == NULL) {
|
if (!fgets(line2, sizeof(line2), stdin)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
line2[strcspn(line2, "\n")] = '\0';
|
line2[strcspn(line2, "\n")] = '\0';
|
||||||
@ -36,7 +36,8 @@ int read_pizza(struct pizza *item) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(item->name, line1);
|
strcpy(item->name, line1, LINESIZE - 1);
|
||||||
|
item->name[LINESIZE - 1] = '\0';
|
||||||
item->price = value;
|
item->price = value;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -73,7 +74,7 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//ukoncit ak ziadne polozky
|
//ukoncit ak ziadne polozky
|
||||||
if (count == 0) {
|
if (count <= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user