Question #538

Can I use new/delete and malloc/free in one program?

Expert's answer

It is possible, but to free the memory that was allocated by operator new you have to use operator delete, and for the memory allocated by malloc – operator free. You should not mix them – it may lead to the crash of the program. The reason is that allocating the memory operator new leaves special marks for the allocated block which are then used for its release.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS