473,396 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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....???
Jun 27 '08 #1
5 3581
aa*****@gmail.com wrote:
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
Jun 27 '08 #2
aa*****@gmail.com said:
Hi all,

why printf("....%d",sizeof((int)(double)(char) i)) always gives the
size of int ???
What did you want it to give the size of?

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #3
On Apr 15, 1:47 pm, "Joachim Schmitz" <nospam.j...@schmitz-digital.de>
wrote:
aark...@gmail.com wrote:
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
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
Jun 27 '08 #4
aark...@gmail.com wrote:
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.

--
Peter
Jun 27 '08 #5
Ivar wrote:
On Apr 15, 1:47 pm, "Joachim Schmitz" <nospam.j...@schmitz-digital.de>
wrote:
>aark...@gmail.com wrote:
>>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

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 8-)

Bye, Jojo
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: John Nagle | last post by:
I've been parsing existing HTML with BeautifulSoup, and occasionally hit content which has something like "Design & Advertising", that is, an "&" instead of an "&amp;". Is there some way I can get...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.