number of bytes for a type in C++

Discussion in 'C Programming' started by Carl Muller, Dec 12, 2004.

  1. Carl Muller

    Carl Muller Guest

    >In C++, the amount of memory used to store int is 4 bytes,
    >or dependent upon the hardware?


    On the compiler/cpu I use, int uses 1 byte, but the byte has 16 bits
    so it can hold a value between -32768 and 32767.
    So sizeof(char) == sizeof(short) == sizeof(int) == 1 which is 16 bits,
    but sizeof(long) == 2 which is 32 bits.

    This is valid (but not common) for both the C and C++ standards.
    Carl Muller, Dec 12, 2004
    #1
    1. Advertising

  2. Carl Muller

    hari4063 Guest

    On what platform and compiler?

    Zaharije Pasalic
    hari4063, Dec 13, 2004
    #2
    1. Advertising

  3. Carl Muller

    Guest

    hari4063 wrote:
    > On what platform and compiler?
    >
    > Zaharije Pasalic

    The micro-n-sp, with the manufacturer's compiler (www.sunplus.com.tw)
    , Dec 13, 2004
    #3
  4. Carl Muller

    hari4063 Guest

    Wow.... Interesting. Thanks lot.

    Best,
    Zaharije Pasalic
    hari4063, Dec 13, 2004
    #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. Jason Collins
    Replies:
    3
    Views:
    5,992
    Jason Collins
    Feb 18, 2004
  2. Replies:
    6
    Views:
    411
    Rolf Magnus
    Dec 10, 2004
  3. Carl Muller

    number of bytes for a type in C++

    Carl Muller, Dec 12, 2004, in forum: C++
    Replies:
    0
    Views:
    343
    Carl Muller
    Dec 12, 2004
  4. mrby

    4-bytes or 8-bytes alignment?

    mrby, Nov 2, 2004, in forum: C Programming
    Replies:
    8
    Views:
    402
    Mark McIntyre
    Nov 2, 2004
  5. number of bytes for a type in C++

    , Dec 10, 2004, in forum: C Programming
    Replies:
    5
    Views:
    335
    Keith Thompson
    Dec 10, 2004
Loading...

Share This Page