What is size_t

beginner c++11

In C++ size_t is an unsigned integer like uint32_t but it has a platform specific maximum value. Being unsigned means size_t values have a range of 0 to your platform’s size_t maximum. C++ uses size_t to represent the maximum size of an object or array you can allocate. This means it’s a useful array index because no array can be sized larger than the maximum value of size_t.

#include <stddef.h> // size_t
#include <limits> 
#include <iostream>

int main() {
  std::cout << std::numeric_limits<size_t>::max() << "\n";
}
18446744073709551615


For more C++ By Example, click here.