I think you are wrong about casting malloc is bad practice. You will get a compiler warning if you don't! It's total rubbish that it's bad practice! If you are not getting compiler warnings, then you aren't using a high enough warning level! It's more an inconvenience than anything else, that's why C++ created the Auto keyword, but even then you would need to cast it so that auto can infer the correct type.
I think it is also worth explicitly stating that these days C and C++ are very different languages. (All too often I see people conflating the two or just saying C/C++, when they really mean one or the other...)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Casting the result of malloc is unnecessary and very bad practice.
Bad:
Good:
I think you are wrong about casting malloc is bad practice. You will get a compiler warning if you don't! It's total rubbish that it's bad practice! If you are not getting compiler warnings, then you aren't using a high enough warning level! It's more an inconvenience than anything else, that's why C++ created the Auto keyword, but even then you would need to cast it so that auto can infer the correct type.
stackoverflow.com/a/605858/9815377
It's important to stress that we're talking about C, not C++
Indeed.
I think it is also worth explicitly stating that these days C and C++ are very different languages. (All too often I see people conflating the two or just saying C/C++, when they really mean one or the other...)