To be pedantic, in general case literals themselves do not have physical size. It makes little sense to apply the notion of "size in bytes" to something that is not "material", i.e. does not reside in memory. The only exception here is string literal "7"
, which is an lvalue. Meanwhile, '7'
and 7.0
are not lvalues.
Anyway, when you apply sizeof
to a literal value (if that's what you meant by "size in bytes"), the literal is interpreted as a simple expression. And what you get is size of the type that expression has. So, '7'
has type char
and size 1, 7.0
has type double
and size sizeof(double)
(implementation dependent), "7"
has type const char[2]
and size 2.
(Note that array-to-pointer conversion is not applied to the immediate operand of sizeof
, which is why sizeof "7"
evaluates to array size, not to pointer size.)