How to cast the size_t to double or int C++

A cast, as Blaz Bratanic suggested: is likely to silence the warning (though in principle a compiler can warn about anything it likes, even if there’s a cast). But it doesn’t solve the problem that the warning was telling you about, namely that a conversion from size_t to int really could overflow. If at all … Read more

unsigned int vs. size_t

The size_t type is the unsigned integer type that is the result of the sizeof operator (and the offsetof operator), so it is guaranteed to be big enough to contain the size of the biggest object your system can handle (e.g., a static array of 8Gb). The size_t type may be bigger than, equal to, or smaller than an unsigned int, and your compiler … Read more

What is size_t in C?

According to the 1999 ISO C standard (C99), size_t is an unsigned integer type of at least 16 bit (see sections 7.17 and 7.18.3). size_tis an unsigned data type defined by several C/C++ standards, e.g. the C99 ISO/IEC 9899 standard, that is defined in stddef.h.1 It can be further imported by inclusion of stdlib.h as … Read more