printf("....%d",sizeof((int)(double)(char) i))

A

aarklon

Hi all,

why printf("....%d",sizeof((int)(double)(char) i)) always gives the
size of int ???

is it because sizeof doesn't evaluate its operand....???
 
J

Joachim Schmitz

Hi all,

why printf("....%d",sizeof((int)(double)(char) i)) always gives the
size of int ???

is it because sizeof doesn't evaluate its operand....???
It is because your code is just the longer version of
printf("....%d",sizeof(int))

Bye, Jojo
 
I

Ivar

It is because your code is just the longer version of
printf("....%d",sizeof(int))

Bye, Jojo

By doing printf("....%d",sizeof((int)(double)(char) i)), you're
finally casting i to an int, so it would print the sizeof(int) value.
Correct me if I'm wrong
 
P

Peter Nilsson

why printf("....%d",sizeof((int)(double)(char) i)) always gives
the size of int ???

is it because sizeof doesn't evaluate its operand....???

With the exception of variable length arrays in C99, yes.

The object i doesn't even have to be initialised. Even the
following is valid...

sizeof( (int) (int (*)(void)) -1 )

....even though there is no well defined conversion involved
at any stage.
 
J

Joachim Schmitz

Ivar said:
By doing printf("....%d",sizeof((int)(double)(char) i)), you're
finally casting i to an int, so it would print the sizeof(int) value.
Exactly, and that's what I said...
Correct me if I'm wrong
No need :cool:

Bye, Jojo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top