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