val is a pointer to char. This can be set to either -valid or invalid-. The if statement will simply check if val does not matter:
if(val)
equivalently
if(NULL != val)
equivalently
if((void*)0 != val)
However, the pointer may indicate an invalid location, for example, memory that is not in the address space of your application. Therefore, it is very important to initialize pointers to 0, otherwise they will point to undefined locations. In the worst case, this location may be valid and you will not notice an error.
mnemosyn
source share