Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

BattleGuard

sizeof???

This topic is 5572 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, this book I have been following uses the sizeof operator, and I have no clue what exactly that does. All I know is that it returns the size of the data provided after the keyword, sizeof. What kind of data type does the compiler return??? I use VC++ .NET, and I already tried the help!!! So HELLPPP!!!! Battleguard My hobbies: Martial Arts, Computer/laptop, Listening to Linkin Park, Computer/laptop, programming, game-dev (that''s why the heck I''m on this site in the first place!!! And did I mention my computer/laptop???

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by ah_bk88
the result of a sizeof int is 2 (4 in VC++) long is 4, etc.


sizeof(int)==4 on any 32 bit OS, not just in VC++

Share this post


Link to post
Share on other sites
quote:
Original post by BattleGuard
Hi, this book I have been following uses the sizeof operator, and I have no clue what exactly that does. All I know is that it returns the size of the data provided after the keyword, sizeof. What kind of data type does the compiler return??? I use VC++ .NET, and I already tried the help!!! So HELLPPP!!!!

Battleguard

My hobbies:
Martial Arts, Computer/laptop, Listening to Linkin Park, Computer/laptop, programming, game-dev (that''s why the heck I''m on this site in the first place!!! And did I mention my computer/laptop???


The returned datatype is size_t

Share this post


Link to post
Share on other sites
quote:
Original post by glassJAw
sizeof(int)==4 on any 32 bit OS, not just in VC++

Your opinion is wrong. Read up on the C/C++ standard. The precise size is left up to the discretion of the compiler.


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
Ok, thanx guys, for that, I tried fiddling with the thing and replaces string with long, int, etc. and got differen values...

Again, Thanx

BattleGuard

My hobbies:
Martial Arts, Computer/laptop, Listening to Linkin Park, Computer/laptop, programming, game-dev (that''s why the heck I''m on this site in the first place!!! And did I mention my computer/laptop???

Share this post


Link to post
Share on other sites
quote:
Original post by Sneftel
quote:
Original post by glassJAw
sizeof(int)==4 on any 32 bit OS, not just in VC++

Your opinion is wrong. Read up on the C/C++ standard. The precise size is left up to the discretion of the compiler.


How appropriate. You fight like a cow.

Oh, well I was under the impression that most compilers under Win32 returned 4 from sizeof(int), not just VC++

Share this post


Link to post
Share on other sites
quote:
Original post by Sneftel
quote:
Original post by glassJAw
sizeof(int)==4 on any 32 bit OS, not just in VC++

Your opinion is wrong. Read up on the C/C++ standard. The precise size is left up to the discretion of the compiler.


...and the compiler, though according to the C++ standard it doesn''t have to, will always pick the size used by the underlying system, which for a 32-bit system like Win32 is 4 bytes.

Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.

Share this post


Link to post
Share on other sites
quote:

though according to the C++ standard it doesn''t have to,
will always pick the size



So which should we rely on? The standard or the convention?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!