Home c++ What is the size_t type?

What is the size_t type?




Answer 1, authority 100%

Open cplusplus.com – size_t and read

Unsigned integral type

unsigned integer. That is, it is not an int, it is signed.

Alias ​​of one of the fundamental unsigned integer types.

An alias for one of the unsigned fundamental types. (that is, most likely 4 or 8 bytes).

It is a type able to represent the size of any object in bytes: size_t is the type returned by the sizeof operator and is widely used in the standard library to represent sizes and counts.

Answer 2, authority 33%

The size_t type is usually used for loop counters, array indexing, storage of sizes, address arithmetic. Since its size is the same as the size of the pointer. If you use (unsigned int) for these purposes, then on a 64-bit platform there may be problems with the correct operation of the application, as well as a theoretical (at the level of one or two extra instructions) decrease in performance during indexing.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions