4
This commit is contained in:
parent
afa7fe3d51
commit
955d347cc6
@ -38,24 +38,23 @@ int contains_substring(char *food_name, char *ingredient) {
|
||||
|
||||
int main() {
|
||||
char ingredient[100];
|
||||
char food_name[100];
|
||||
char food_name[200];
|
||||
char price[20];
|
||||
int count = 0;
|
||||
|
||||
printf("Zadaj hladanu surovinu: ");
|
||||
scanf("%s", ingredient);
|
||||
printf("Zadaj hladanu surovinu:\n");
|
||||
if (!fgets(ingredient, sizeof(ingredient), stdin)) {
|
||||
return 1;
|
||||
}
|
||||
ingredient[strcspn(ingredient, "\n")] = '\0';
|
||||
|
||||
printf("Zadaj jedalny listok:\n");
|
||||
while (fgets(food_name, sizeof(food_name), stdin)) {
|
||||
if (food_name[strlen(food_name) - 1] == '\n') {
|
||||
food_name[strlen(food_name) - 1] = '\0';
|
||||
}
|
||||
food_name[strcspn(food_name, "\n")] = '\0';
|
||||
if (!fgets(price, sizeof(price), stdin)) {
|
||||
break;
|
||||
}
|
||||
if (price[strlen(price) - 1] == '\n') {
|
||||
price[strlen(price) - 1] = '\0';
|
||||
}
|
||||
price[strcspn(price, "\n")] = '\0';
|
||||
|
||||
if (contains_substring(food_name, ingredient)) {
|
||||
printf("%s\n%s\n", food_name, price);
|
||||
|
Loading…
Reference in New Issue
Block a user