Regarding sizeof operator

Discussion in 'C Programming' started by venkat, Mar 5, 2007.

  1. venkat

    venkat Guest

    Hi,
    I am new to c programming language. I heard that , sizeof can be
    made as run time operator. Even though it is a compile time operator.
    I am not sure also whether sizeof can be made as run time operator. If
    it can be made as run time operator, Please clarify me how to make it
    as run time operator?. what configurations have to do , to get this
    behavior.
    Please clarify my doubt.

    Thanks,
    Venkat.
    venkat, Mar 5, 2007
    #1
    1. Advertising

  2. venkat

    Chris Dollin Guest

    venkat wrote:

    > Hi,
    > I am new to c programming language. I heard that , sizeof can be
    > made as run time operator. Even though it is a compile time operator.
    > I am not sure also whether sizeof can be made as run time operator. If
    > it can be made as run time operator, Please clarify me how to make it
    > as run time operator?. what configurations have to do , to get this
    > behavior.


    `sizeof` is calculated at compile-time unless its operand is a
    (C99-specific) variable-length array.

    Some particular uses of `sizeof` can be re-expressed using `&`,
    `[]`, and `-` operators, but the compiler will be quite at
    liberty to optimise them away and so still have no run-time
    code for them. And anyway, given that `sizeof` is a language
    feature, why bother with imitations?

    --
    Chris "electric hedgehog" Dollin
    Meaning precedes definition.
    Chris Dollin, Mar 5, 2007
    #2
    1. Advertising

  3. venkat

    santosh Guest

    venkat wrote:
    > Hi,
    > I am new to c programming language. I heard that , sizeof can be
    > made as run time operator. Even though it is a compile time operator.
    > I am not sure also whether sizeof can be made as run time operator. If
    > it can be made as run time operator, Please clarify me how to make it
    > as run time operator?. what configurations have to do , to get this
    > behavior.
    > Please clarify my doubt.


    This particular question seems to be a curious obsession with newbies.
    Search this group's archive in Google Groups. This has been discussed
    time and time again. Use a search string like "Implementing sizeof."
    santosh, Mar 5, 2007
    #3
  4. In article <>,
    santosh <> wrote:

    >> I am new to c programming language. I heard that , sizeof can be
    >> made as run time operator. Even though it is a compile time operator.
    >> I am not sure also whether sizeof can be made as run time operator. If
    >> it can be made as run time operator, Please clarify me how to make it
    >> as run time operator?. what configurations have to do , to get this
    >> behavior.


    >This particular question seems to be a curious obsession with newbies.


    I suspect that it's a homework question set in some C programming
    course, probably in India, since many of the people asking this and
    similar questions have Indian-sounding names.

    -- Richard

    --
    "Consideration shall be given to the need for as many as 32 characters
    in some alphabets" - X3.4, 1963.
    Richard Tobin, Mar 5, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sonu

    Regarding sizeof Operator

    sonu, Mar 14, 2006, in forum: C Programming
    Replies:
    12
    Views:
    519
    Micah Cowan
    Mar 14, 2006
  2. pratap
    Replies:
    0
    Views:
    282
    pratap
    Aug 19, 2007
  3. pratap
    Replies:
    1
    Views:
    325
    Rolf Magnus
    Aug 20, 2007
  4. pratap
    Replies:
    3
    Views:
    253
    =?ISO-8859-1?Q?Erik_Wikstr=F6m?=
    Aug 20, 2007
  5. Kislay

    The sizeof operator : sizeof(++i)

    Kislay, Oct 18, 2007, in forum: C Programming
    Replies:
    10
    Views:
    673
    Peter Pichler
    Oct 19, 2007
Loading...

Share This Page