What's the difference between size_t and int in C++? -


In many C ++ examples, I see type size_t, where I use a simple int. What is the difference, and why should size_t be better?

from:

stdlib.h and stddef.h header files Defines a datatype that is used to represent the size of an object called size_t . The functions which library functions take, they expect that they type type size_t, and the sizeof operator evaluates for size_t.

The actual type of shape is platform-dependent; A common mistake is size_t to assume that is similar to unsigned int, which can lead to programming errors, especially 64-bit architectures become more common.

Also, check


Comments