bgc
bgc copied to clipboard
5.7: Missing "printf()" (and some parentheses)?
The example program is written this way:
sizeof(int); // Returns size of an `int`
sizeof p // p is type int*, so returns size of `int*`
sizeof *p // *p is type int, so returns size of `int`
Shouldn't it use printf() instead, so that readers can observe themselves what is getting returned (especially those who copypaste and then troubleshoot)? And shouldn't sizeof() always accept arguments in parentheses?
printf("%zu\n", sizeof(int)); // Returns size of an `int`
printf("%zu\n", sizeof(p)); // p is type int*, so returns size of `int*`
printf("%zu\n", sizeof(*p)); // *p is type int, so returns size of `int`