C does not store values the same way as Javascript or Python. In C, there's no such thing as a variable without value. You can never determine if a variable is initialized or not only by looking at the variable itself. A variable can be uninitialized, but using the variable then would lead to undefined behavior and the most likely consequence of ub in this case is that you get a random value that has a high probability of being zero.
If you do the declaration float f
, then you reserve a certain amount of memory (usually 4 bytes for a float). Each time you use f
in an expression, then whatever bit pattern that is found at the address &f
will be interpreted as a float. Some bit patterns may be special for floats but NULL is not one of them, but when it comes to integers, then EVERY bit pattern is a valid regular integer.
You simply have to make sure that tab
is properly initialized before passing it to your function. The function itself cannot determine if that's the case.
In C, NULL is a constant, usually of type void*
, but it may also be of type int
. The intended purpose is for pointers and should not be used for anything else.
Furthermore, C is a statically typed language, which means that a variable can never change type. A float can never contain letters. You can, via casting, make a float to contain the same bit pattern as an integer, a four character string, a pointer or something else, but most likely the result would not make sense.