scanf GCC for long double [duplicate]

This question already has an answer here:

I’m using gcc 4.8.1 with std=c99 on Windows 7. What’s the correct place holder for long double when using scanf and fscanf? I tried %lf and %Lf and neither is working. Compile command is gcc -std=c99 main.c -o main.exe. When I omit std=c99 it works fine.

#include <stdlib.h>
#include <stdio.h>
int main()
    long double x = 0;
    scanf("%Lf", &x); 
    printf("x = %Lfn", x); 
    return 0; 

Source: gcc

Leave a Reply