+ 1
C - Why "a" has the size of an int?
#include <stdio.h> int main() { float a = 10.5; printf("%d %d", sizeof(a), sizeof(10.5)); return 0; }
2 Respostas
+ 4
Aren't the size of int and float the same.
+ 3
I just want to add that floating point literals that are defined without a suffix like 'f' are by default treated as double values, therefore the sizes of sizeof( a ) and sizeof( 10.5 ) might differ since 'a' is of type float but 10.5 is of type double.