Use the %lf
format specifier to read a double:
double a;
scanf("%lf",&a);
Wikipedia has a decent reference for available format specifiers.
You’ll need to use the %lf
format specifier to print out the results as well:
printf("%lf %lf",a,b);
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?
- Why does scanf() need “%lf” for doubles, when printf() is okay with just “%f”?
- C – scanf() vs gets() vs fgets()
- Scanf skips every other while loop in C
- 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]
- Why does scanf require &?
- 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”)
- How to skip a line when fscanning a text file?
- 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?
- scanf not working. need to read double from console
- Scan multiple integers without knowing the actual number of integers