| re: How many bytes in a string?
As weaknessforcats said, using the sizeof operator, like this:
sizeof(string)
will give you the amount of space that a string object takes up on the stack on your particular platform, that is, the amount of space that string objects are guarunteed to take up, even before you put any characters into them. But string objects, unlike the other types you have been finding the size of, have space allocated on the heap, which is where the characters are stored. There is no easy way of finding out how much space a string object is taking up on the heap, and it can change while your program is running, as you add and remove characters from the string.
enum is not really a type. It's more of a way of defining your own types. However, when you declare a variable to be of a type that you have defined with enum, I think it's the same size as an int.
Did you find out the sizes in your table with the sizeof operator? If you didn't, try using the sizeof operator on all those types to see if it matches what's in your table. Then you can find out what the sizes of strings and enum types are too.
Hope this helps.
|