How many bits does a data type created with struct use?

This is a discussion on How many bits does a data type created with struct use? within the C++ Programming forums, part of the General Programming Boards category; Thanks! Is it the same with enum too?...

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    6

    How many bits does a data type created with struct use?

    Thanks!

    Is it the same with enum too?

  2. #2
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    A struct may or may not take up the same amount of space as an enum.
    You can do sizeof(struct structname) to get the # of bytes used by a struct. The same likely works for enum (never tried).
    Regardless, a well written program will not depend of the size of a struct. (The size may not be the same on every platform.)
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  3. #3
    For Narnia! Sentral's Avatar
    Join Date
    May 2005
    Location
    Narnia
    Posts
    719
    The size of a struct object, with no members in the struct is one byte. I think an enum object is 4 bytes.
    Videogame Memories!
    A site dedicated to keeping videogame memories alive!

    http://www.videogamememories.com/
    Share your experiences with us now!

    "We will game forever!"

  4. #4
    Registered User
    Join Date
    Mar 2007
    Posts
    6
    thanks for your help guys

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Assignment HELP!!
    By cprogrammer22 in forum C Programming
    Replies: 35
    Last Post: 01-24-2009, 01:24 PM
  3. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  4. towers of hanoi problem
    By aik_21 in forum C Programming
    Replies: 1
    Last Post: 10-02-2004, 01:34 PM
  5. Tutorial review
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-22-2004, 08:40 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21