Great approach, trying other things to evaluate differences. While it is true that you "do it exactly as he does it, ". It is the computer that is doing something different. Notice the difference between the clang in the course video (below) and the clang in your terminal window
There have been many changes to the class environment since the video was made, some very subtle like this one.
The compiler itself is giving you guidance. The operator
sizeof returns a value of type
size_t. size_t is defined in some header file as an unsigned long. You need to use the (suggested) format string
%lu, which means
long unsigned. It is basically preventing an overflow error, because sizeof() can return a value much bigger than "%i" can handle.
In the second and third examples, "%i" is a valid format string for char or integer, so the compiler does not complain about the format string. But it is not valid for
char c = sizeof(c) has the same potential to overflow c as the printf. I don't know the compiler internals or diagnostics well enough to explain why it is doing stricter type matching in the case of printf.