The only argument in favor of supporting printf(“%s”, NULL) -> “(null)” that comes to my mind is to aid debugging. Using something like fprintf(stderr, “Whatever: %s”, s) for debugging and getting a “Whatever: (null)” back is somewhat more helpful than the process crashing.
That said I believe the advantages of not supporting NULL in printf outweight the disadvantages: Simpler code, early crashes in case of unexpected NULL and you can’t count on (null) working anyway, because it’s not required by any standard.
The only argument in favor of supporting printf(“%s”, NULL) -> “(null)” that comes to my mind is to aid debugging. Using something like fprintf(stderr, “Whatever: %s”, s) for debugging and getting a “Whatever: (null)” back is somewhat more helpful than the process crashing.
That said I believe the advantages of not supporting NULL in printf outweight the disadvantages: Simpler code, early crashes in case of unexpected NULL and you can’t count on (null) working anyway, because it’s not required by any standard.