fixed up the first input section of the code before implementing a new one

This commit is contained in:
dvorakmortonxd 2026-05-25 21:24:29 +02:00
commit eb6781b969

7
main.c
View file

@ -123,14 +123,15 @@ int main() {
LOIS.weight = 60;
printf("Our woman is unknown, she is not %d years old and she weights %dkg. (LOIS.age and LOIS.weight).", LOIS.age, LOIS.weight);
// INPUT
// INPUT (BUT ONLY FOR ONE WORD! STOPS WHEN YOU PUT IN A SPACE)
printf("\n\nINPUT BELOW:\n"); // DIVIDER
char fruit[20]; //MAX 20 CHARACTERS
printf("Pick a fruit: ");
char fruit[50]; //MAX 50 CHARACTERS
printf("Pick a fruit (SINGLE WORD, EVERYTHING ELSE GETS IGNORED): ");
fflush(stdout); // this forces the buffer to print NOW, fixing the "bug" in which it prints out everything AFTER the next line (scanf)
scanf("%s", fruit);
printf("\nYou choose %s as your fruit!", fruit);
// END
return 0;
// THIS IS THE CURRENT END OF MY LESSON