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

This commit is contained in:
Yevhen Kozirovskyi 2024-10-02 17:00:34 +00:00
parent f61d976748
commit e80e1a83fe

View File

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