0

Printf("float: %ld", sizeof(float)); in this code if I give %lf instead of %ld it shows 0.000000 why? Why it not shows 4.0?

16th Dec 2020, 5:18 AM
shahi Nadaf
shahi Nadaf - avatar
2 Respuestas
16th Dec 2020, 5:47 AM
Krish
Krish - avatar
+ 3
`sizeof` operator returns a `size_t` type value, which is an unsigned integer value "%lu" or "%zu" is meant for `size_t` which is an unsigned integer type. "%lf" is meant for `double` which is a floating point type In short, inappropriate format specifier gives us unpredictable result, so take care when choosing format specifiers, pick one that suits the data type of argument to be printed or read.
16th Dec 2020, 6:35 AM
Ipang