%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
.
More Related Contents:
- How do you type something on the same line of text in C [closed]
- Disadvantages of scanf
- How to use sscanf in loops?
- Why does scanf ask twice for input when there’s a newline at the end of the format string?
- How to prevent SIGPIPEs (or handle them properly)
- C: Multiple scanf’s, when I enter in a value for one scanf it skips the second scanf [duplicate]
- When should I use ampersand with scanf()
- How to read a line from the console in C?
- scanf: “%[^\n]” skips the 2nd input but ” %[^\n]” does not. why?
- What does space in scanf mean? [duplicate]
- Reading a line using scanf() not good?
- Does scanf() take ‘\n’ as input leftover from previous scanf()?
- printf not printing on console
- Going through a text file line by line in C
- difference between %ms and %s scanf
- Reading a single character in C
- Max string length using scanf -> ANSI C
- Get scanf to quit when it reads a newline?
- C – trying to read a single char from stdin (and failing) w/ scanf / getchar
- Program doesn’t execute gets() after scanf(), even using fflush(stdin)
- Why is adding a leading space in a scanf format string recommended?
- If statements not working?
- What is the correct printf specifier for printing pid_t
- While-loop ignores scanf the second time
- SegFault after scanf?
- C programming – Loop until user inputs number scanf
- How can one flush input stream in C?
- Read int values from a text file in C
- Return value of fgets()
- Scan multiple integers without knowing the actual number of integers