-2

i have written the below code in C language.

#include <stdio.h>
#include <limits.h>
#include <float.h>

int main(void) {
    printf("Long Double range: %lf, %lf\n", LDBL_MIN, LDBL_MAX);
}

when I compile it (with gcc (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008), it shows the below warning!!!

warning: format ‘%lf’ expects argument of type ‘double’, but argument 2 has type ‘long double’ 

how can i resolve this warning? i have used also %le and %lg, but warning resists!

Mahdi
  • 187
  • 2
  • 14

1 Answers1

4

If you want to print a long double value, you must use the placeholder %Lf.

pmg
  • 106,608
  • 13
  • 126
  • 198
Rohan Bari
  • 7,482
  • 3
  • 14
  • 34