Because C will promote floats to doubles for functions that take variable arguments. Pointers aren’t promoted to anything, so you should be using %lf
, %lg
or %le
(or %la
in C99) to read in doubles.
More Related Contents:
- Hangman code in C
- ‘ ‘, ‘\n’ , scanf() and output screen
- sscanf Beginner in C
- i get Error while trying to compile and Run, [Linker error] undefined reference to `scand’ [closed]
- Segmentation fault using scanf() [closed]
- What is the effect of trailing white space in a scanf() format string?
- How to prevent scanf causing a buffer overflow in C?
- How to do scanf for single char in C [duplicate]
- How can I read an input string of unknown length?
- Program doesn’t wait for user input with scanf(“%c”,&yn);
- C/C++ printf() before scanf() issue
- What does the scanf function return?
- Reading string from input with space character? [duplicate]
- Parsing input with scanf in C
- scanf regex – C
- What is the difference between sscanf or atoi to convert a string to an integer?
- string format for intptr_t and uintptr_t
- scanf won’t ask for input the second time [duplicate]
- Why does a space in my scanf statement make a difference? [duplicate]
- Difference between scanf(“%c”, &c) and scanf(” %c”, &c) [duplicate]
- What is the format specifier for unsigned short int?
- Reading numbers from a text file into an array in C
- Dynamic String Input – using scanf(“%as”)
- Why does scanf() need & operator (address-of) in some cases, and not others? [duplicate]
- How to use int16_t or int32_t with functions like scanf [duplicate]
- whitespace in the format string (scanf)
- How to use sscanf correctly and safely
- How do the puts and gets functions work?
- Read int values from a text file in C
- Getting multiple values with scanf()