scanf not working. need to read double from console

%f is looking for a float, not a double. If you want to use a double, use the format %lf.

As a somewhat interesting aside, clang warns about this without any extra flags, gcc 4.6 won’t warn about it even with -Wall -Wextra -pedantic.

Leave a Comment