2 ms·
Size_t is guaranteed to hold values up to 65535. That's twice as long as int and much smaller than long.
by marcosdumay 8y ago
Size_t is guaranteed to hold values up to 65535. That's twice as long as int and much smaller than long.
- mikeash 8y agosize_t is guaranteed to hold values large enough to index into any array you can allocate. On a 64-bit system with an allocator that supports allocations larger than 4GB, that means size_t has to be larger than 32 bits. If it's an LLP64 system, size_t will be larger than long. If the value represents an index or size of something in memory, use size_t. Consider ssize_t if you need negative values and are certain you never need the larger half of the size_t range.