An array can not be null. Null is state of a pointer, and an array is not a pointer.
In the expression !str, the array will decay to the address of the first element. The type of this decayed address is a pointer, but you cannot modify the decayed pointer. Since the array is never stored in the address 0 (except maybe in some special case on an embedded system where an array might actually be stored at that memory location), !str will never be true.
What you can do, is initialize all of the sub-objects of the array to zero. This can be achieved using the value-initialization syntax:
char str[5]{};
As I explained earlier, !str is still not meaningful, and is always false. One sensible thing that you might do is check whether the array contains an empty string. An empty string contains nothing except the terminator character (the array can have elements after the terminator, but those are not part of the string).
Simplest way to check whether a string is empty is to check whether the first character is the terminator (value-initialized character will be a terminator, so a value initialized character array does indeed contain the empty string):
if (!str[0]) // true if the string is empty
char *str = NULL;Are you planning to modifystrlater or it remainsNULL?if(!str)you are checking if the pointer tostrisNULLnot if the content is0x0if(!str)- will never be true.stris an automatic variable with a determinate, non-null address. It does not have, and never will have, an expression value ofNULL. You need something that can holdNULL, and that is a pointer.char *str = NULL;, for example.