Original Post
What exactly is a size_t data type?
Quote:
Original post by Konfusius
size_t is defined as the data type that is returned by the sizeof operator.
Quote:
To elaborate further size_t is a type alias for some unsigned integral type (does not necessarily mean unsigned int) used to refer to sizes, subscript access for operator overloading etc.
Quote:
Original post by LessBread
To clarify, sizes means number of bytes. The sizeof operator returns the size in bytes of its operand.
Quote:
Original post by desertcube
sizeof actually returns the size in number of char's, which generally speaking is one byte, but worth remebering. See MSDN for details.
Quote:
Original post by desertcube Quote:
Original post by LessBread
To clarify, sizes means number of bytes. The sizeof operator returns the size in bytes of its operand.
sizeof actually returns the size in number of char's, which generally speaking is one byte, but worth remebering. See MSDN for details.
Quote:
When the sizeof operator is applied to an object of type char, it yields 1. When the sizeof operator is applied to an array, it yields the total number of bytes in that array, not the size of the pointer represented by the array identifier.
Quote:
Original post by SiCrane Quote:
Original post by desertcube
sizeof actually returns the size in number of char's, which generally speaking is one byte, but worth remebering. See MSDN for details.
The sizeof a char is defined to be one byte. If an implementation has a sizeof(char) != 1 then it isn't compliant with the C++ standard.
Quote:
Original post by pants
sizeof(char) == 1 because sizeof returns the # of chars not the # of bytes. A char is not guaranteed to be 1 byte, just like an integer, short, long or byte are not guaranteed to be specific sizes.
Quote:
Really? So what do you think sections 1.7 and 5.3.3 in the standard mean?
Quote:
Original post by pants
sizeof(char) == 1 because sizeof returns the # of chars not the # of bytes. A char is not guaranteed to be 1 byte, just like an integer, short, long or byte are not guaranteed to be specific sizes.
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more