Home  >  Article  >  Backend Development  >  Why check for NULL pointer before deleting in C/C++?

Why check for NULL pointer before deleting in C/C++?

WBOY
WBOYforward
2023-08-25 16:37:11864browse

Why check for NULL pointer before deleting in C/C++?

Checking a NULL pointer before deleting is basically pointless. If the pointer is set to NULL, deleting the pointer does nothing. This may be a reason for checking for NULL pointers, and deleting a pointer that has been set to NULL may indicate a bug in the program.

The above is the detailed content of Why check for NULL pointer before deleting in C/C++?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete