diff --git a/cv1/program.c b/cv1/program.c index 808b531..86ed403 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -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);