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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • aarklon@gmail.com

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

    Hi all,

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

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

    #2
    Re: printf(".. ..%d",size of((int)(double )(char) i))

    aarklon@gmail.c om wrote:
    Hi all,
    >
    why printf("....%d" ,sizeof((int)(d ouble)(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


    Comment

    • Richard Heathfield

      #3
      Re: printf(".. ..%d",size of((int)(double )(char) i))

      aarklon@gmail.c om said:
      Hi all,
      >
      why printf("....%d" ,sizeof((int)(d ouble)(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

      Comment

      • Ivar

        #4
        Re: printf(&quot;.. ..%d&quot;,size of((int)(double )(char) i))

        On Apr 15, 1:47 pm, "Joachim Schmitz" <nospam.j...@sc hmitz-digital.de>
        wrote:
        aark...@gmail.c om wrote:
        Hi all,
        >
        why printf("....%d" ,sizeof((int)(d ouble)(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)(d ouble)(char) i)), you're
        finally casting i to an int, so it would print the sizeof(int) value.
        Correct me if I'm wrong

        Comment

        • Peter Nilsson

          #5
          Re: printf(&quot;.. ..%d&quot;,size of((int)(double )(char) i))

          aark...@gmail.c om wrote:
          why printf("....%d" ,sizeof((int)(d ouble)(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

          Comment

          • Joachim Schmitz

            #6
            Re: printf(&quot;.. ..%d&quot;,size of((int)(double )(char) i))

            Ivar wrote:
            On Apr 15, 1:47 pm, "Joachim Schmitz" <nospam.j...@sc hmitz-digital.de>
            wrote:
            >aark...@gmail. com wrote:
            >>Hi all,
            >>
            >>why printf("....%d" ,sizeof((int)(d ouble)(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(in t))
            >>
            >Bye, Jojo
            >
            By doing printf("....%d" ,sizeof((int)(d ouble)(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


            Comment

            Working...