I am getting confused with size_t
in C. I know that it is returned by the sizeof
operator. But what exactly is it? Is it a data type?
Let\'
If you are the empirical type,
echo | gcc -E -xc -include 'stddef.h' - | grep size_t
Output for Ubuntu 14.04 64-bit GCC 4.8:
typedef long unsigned int size_t;
Note that stddef.h
is provided by GCC and not glibc under src/gcc/ginclude/stddef.h
in GCC 4.2.
Interesting C99 appearances
malloc
takes size_t
as an argument, so it determines the maximum size that may be allocated.
And since it is also returned by sizeof
, I think it limits the maximum size of any array.
See also: What is the maximum size of an array in C?