size_t vs. uintptr_t

The C standard guarantees that size_t is a type that can hold any array index. This means that, logically, size_t should be able to hold any pointer type. I’ve read on some sites that I found on the Googles that this is legal and/or should always work: void *v = malloc(10); size_t s = (size_t) … Read more

unsigned int vs. size_t

I notice that modern C and C++ code seems to use size_t instead of int/unsigned int pretty much everywhere – from parameters for C string functions to the STL. I am curious as to the reason for this and the benefits it brings. 8 s 8 The size_t type is the unsigned integer type that … Read more

What is size_t in C?

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’s say I have a for loop: for(i = 0; i < some_size; i++) Should I use int i; or size_t i;? 15 s 15 From Wikipedia: … Read more