+ 2

size_t

Can you explain to me what is "size_t" type? thank you

2nd Jan 2018, 1:44 PM
simo87
5 Answers
+ 10
According to http://en.cppreference.com/w/cpp/types/size_t size_t is an unsigned integer value which is returned by the sizeof operator, which means we can safely assume that size_t can store the maximum size of any object. According to https://stackoverflow.com/questions/216259/is-there-a-max-array-length-limit-in-c The maximum size of an object is not specified by the C++ standard, and instead by the hardware.
2nd Jan 2018, 1:49 PM
Hatsy Rei
Hatsy Rei - avatar
+ 7
We don't usually use size_t for variables, but you can use the type to store unsigned integer values which can be used for indexing purposes, e.g. array size, const std::size_t N = 10; int* array = new int[N];
2nd Jan 2018, 1:54 PM
Hatsy Rei
Hatsy Rei - avatar
+ 6
size_t is used in C rather than C++ And it is often a typedef for unsigned long
2nd Jan 2018, 2:10 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
0
ok thank you very much , can you give me an eg. of use of it?
2nd Jan 2018, 1:50 PM
simo87