Wie kommt es, dass die Funktion fflush (stdin) nicht funktioniert?

Meine Hauptfrage ist, warum es ist, dass die fflush (stdin); Funktion funktioniert nicht? Immer wenn ich den Code ausführe, kann ich die zweite Eingabe nicht mit Leerzeichen abrufen. Hallo Welt, aber stattdessen bekomme ich Hallo? Vielen Dank

#include <stdio.h>

main(){

    int      x;
    double   y;
    char     string[100];

     /*

      * string input

      */

     printf("Enter one word: ");
     scanf("%s", string);  // note there is no & before string */
     printf("The word you entered was >>%s<<\n");

     printf("Enter many words: ");
     fflush(stdin); // <---- for some reason this function is not working
     scanf("%[^\n]", string); // read up to a newline (multiple words)

     printf("The text you entered was >>%s<<\n");

     getchar();   
}

Antworten auf die Frage(2)

Ihre Antwort auf die Frage