I have a question: the size of a long double
is 16 bytes
, when I check that with sizeof()
there is no problem, it returns 16
but I did this little program to fill a 16 byte string with zeros using a long double
cast, but it fills only 10 bytes of zeros instead of 16, just two more than long
and double
, why does this happen?
#include <stdio.h>
int main(void)
{
char s[17] = "aaaaaaaaaaaaaaaa";
*((long double *)s) = 0.L;
for (int i = 0; i < 16; i++)
printf("%d", (int)s[i]);
write(1, "\n", 1);
return (0);
}
Output:
0000000000979797979797
Instead of:
0000000000000000
And for double
it outputs well:
000000009797979797979797
So why does it work with double
but not long double
?