You need to clear the bad input or it will be read over and over again.
Code:
#include <stdio.h>
 
int main() {
    double d;
 
    while (puts("Enter a double: "), !scanf("%lf", &d))
        for (int c; (c = getchar()) != EOF && c != '\n'; ) ;
 
    return 0;
}