> the program should check for a null pointer and gracefully exit if one is found: ...
If malloc() fails, there is no need to exit the program completely with exit(), only return from the current function with an error.
It is impractical to try to recover/continue your program in an out of memory situation for most programs.
So it is a good advice for beginners.
It is impractical to try to recover/continue your program in an out of memory situation for most programs.
So it is a good advice for beginners.