From 26ced520081d4d485494ecc23e6e665a00489a8d Mon Sep 17 00:00:00 2001 From: dvorakmortonxd Date: Mon, 25 May 2026 21:53:21 +0200 Subject: [PATCH] new input thing that works with spaces too --- main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.c b/main.c index ff6fd5e..2f8e76c 100644 --- a/main.c +++ b/main.c @@ -131,6 +131,14 @@ int main() { scanf("%s", fruit); printf("\nYou choose %s as your fruit!", fruit); + // INPUT (LARGER AMOUNT OF WORDS COMPARED TO SCANF) + printf("\n\nINPUT (larger) BELOW:\n"); // DIVIDER + char vegetable[50]; + printf("Pick a vegetable to go in the salat: "); + fflush(stdout); // same use case as above in the first input part of the code + while (getchar() != '\n') {} // clears the input buffer so it doesnt print out excess input from the fruit one + scanf(" %49[^\n]", vegetable); // the "[^\n]" means to read everything except a newline, which means you can input spaces inside now, 49 makes it so it doesnt crash once it has more than 50 characters + printf("The %s will be a perfect choice for this salat!", vegetable); // END return 0;