I've seen the following in C code and it seems strange to me:
myType GetStuff(size_t *iSize) {
*iSize = (size_t)0;
size_t h = 0;
*iSize += h;
}
Everything works without the cast as well: *iSize = 0;
.
Is there any need for the (size_t)
cast or is it superfluous?
Is there any need in (size_t) cast or its superfluous?
Arithmetic types convert implicitly. You don't need a cast. That said, the cast improves the readability of the code and might avoid some warnings from some compilers.