Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
size of int vs. pointer
Name: L33TRice Date: March 13, 2008 at 03:53:25 Pacific OS: UNIX CPU/Ram: lots Product: SUN
Comment:
Quick question, as far as it goes in C++, what are the sizes of (i.e. bits, or bytes) of ints, and pointers? Specifically which is larger?
Name: Razor2.3 Date: March 13, 2008 at 04:28:57 Pacific
Reply:
In C/C++... A byte is at least 8 bits. char is exactly 1 byte short is at least 16 bits. int is at least 16 bits. long is at least 32 bits. Also: short <= int <= long. Finally: sizeof(int) == sizeof(unsigned int).
A pointer's size is determined by the platform, and has no guaranteed size. Therefore, my answer is, Both and neither.
0
Response Number 2
Name: Whiavi Date: March 13, 2008 at 19:23:02 Pacific
Summary: I'm fairly familiar with pointers in C++, but ran into a problem today. I have a function that I want to be able to take an input of any datatype. As an example, a simple one to find the index of an ...
Summary: This statement is NOT legal because the number of bits declared for test_1 is larger than the size of character (8 bits): struct test { char test_1 : 9; int test_5 : 7; }; This statement is legal: str...
Summary: How can I determine the size of a memory block allocated by malloc? I tried using sizeof on the pointer to the memory block but it returns the size of the pointer and not the memory block. IŽd like to...