Question

In a code-snippet I have seen this:

size_t w = CGImageGetWidth(inImage);

The docs don't give me any useful info about "size_t". Does anyone know what this is?

Was it helpful?

Solution

From here:

Unsigned integral type

size_t corresponds to the integral data type returned by the language operator sizeof and is defined in the header file (among others) as an unsigned integral type.

In <cstring>, it is used as the type of the parameter num in the functions memchr, memcmp, memcpy, memmove, memset, strncat, strncmp, strncpy and strxfrm, which in all cases it is used to specify the maximum number of bytes or characters the function has to affect.

It is also used as the return type for strcspn, strlen, strspn and strxfrm to return sizes and lengths.

OTHER TIPS

size_t is a platform dependent means to represent size of objects. It is always unsigned, but the it can be an unsigned 32 bit value on 32bit platforms or 64 bit value for 64bit platforms. On iPhone SDK is an unsigned long.

size_t is an alias (typedef) for an unsigned integer.

That's a type that's used throughout C and C++ to simply represent an integer. I believe it's just a typedef of int.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top