The whole C language is written with the motto "We'll behave correctly provided the programmer knows what he's doing." The programmer is expected to know to make all the checks he needs to make. It's not just checking for NULL, it's ensuring that dest
points to enough allocated memory to hold src
, it's checking the return value of fopen
to make sure the file really did open successfully, knowing when memcpy
is safe and when memmove
is required, and so on.
Getting strcpy
to check for NULL won't change the language paradigm. You will still need to ensure that dest
points to enough space -- and this is something that strcpy
can't check for without changing the interface. You will also need to ensure that src
is '\0'
-terminated, which again strcpy
can't possibly check.
There are some C standard library functions which do check for NULL: for example, free(NULL)
is always safe. But in general, C expects you to know what you're doing.
[C++ generally eschews the <cstring>
library in favour of std::string
and friends.]