Oooh I didn't know about the first part (it reasoned well in my head), and for the casting of malloc I did mention that it's only necessary in C++, but a good habit in C.
In C++, you generally should use new, not malloc. The only reason to use malloc in C++ is if you have a mixed C/C++ program and C++ code needs to allocate memory that's free'd by C code.
There really is nothing gained by casting malloc in C. There are many things you can do in C that are good habits, but that's not one of them.
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.
Oooh I didn't know about the first part (it reasoned well in my head), and for the casting of
mallocI did mention that it's only necessary in C++, but a good habit in C.In C++, you generally should use
new, notmalloc. The only reason to usemallocin C++ is if you have a mixed C/C++ program and C++ code needs to allocate memory that's free'd by C code.There really is nothing gained by casting
mallocin C. There are many things you can do in C that are good habits, but that's not one of them.