Обновить cv1/program.c

This commit is contained in:
Yevhen Kozirovskyi 2024-10-02 17:05:35 +00:00
parent e80e1a83fe
commit 2a868dd92b

View File

@ -38,6 +38,7 @@ int main() {
if (fgets(name, MAX_NAME_LEN, stdin) == NULL) {
return 0;
}
name[strcspn(name, "\n")] = '\0';
if (strlen(name) == 0) {
break;
@ -45,6 +46,7 @@ int main() {
if (fgets(price, MAX_NAME_LEN, stdin) == NULL) {
return 0;
}
price[strcspn(price, "\n")] = '\0';
strncpy(dishes[count][0], name, MAX_NAME_LEN - 1);
dishes[count][0][MAX_NAME_LEN - 1] = '\0';
@ -65,7 +67,9 @@ int main() {
if (strstr(decoded_name, ingredient) != NULL) {
printf("%s%s", dishes[i][0], dishes[i][1]);
if (i < count - 1) {
printf("\n");
}
}
}
printf("Nacitanych %d poloziek.", count);