char fullName[30] = {NULL};
This is something that should never be written.
NULL
is a macro that expands to a null pointer constant. A character - not a pointer - is being initialised here, so it makes no sense to use NULL
.
It just so happens that some null pointer constants are also integer literals with value 0 (i.e. 0 or 0L for example), and if NULL
expands to such literal, then the shown program is technically well-formed despite the abuse of NULL
. What the macro expands to exactly is defined by the language implementation.
If NULL
instead expands to a null pointer constant that is not an integer literal such as nullptr
- which is entirely possible - then the program is ill-formed.
NULL
shouldn't be written in C++ at all, even to initialise pointers. It exists for backwards compatibility with C to make it easier to port C programs to C++.
Now, let us assume that NULL
happens to expand to an integer literal on this particular implementation of C++.
Nothing in the example is assigned. Assignment is something that is done to pre-existing object. Here, and array is being initialised.
The first element of the array is initialised with the zero literal. The rest of the elements are value initialised. Both result in the null character. As such, the entire array will be filled with null characters.
A simple and correct way to write the same is:
char fullName[30] = {};
B and C are equally close to being correct, except for wording regarding "assignment". They fail to mention value initialisation, but at least the outcome is the same. A is not wrong either, although it is not as complete because it fails to describe how the rest of the elements are initialised.
If "empty" is interpreted as "contains no elements", then D is incorrect because the array contains 30 elements. If it is interpreted as "contains the empty string", then D would be a correct answer.