The question is ill-defined, but Option B seems like the most correct answer.
The result depends on how exactly NULL
is defined, which depends on the compiler (more precisely, on the standard library implementation). If it's defined as nullptr
, the code will not compile. (I don't think any major implementation does that, but still.)
Assuming NULL
is not defined as nullptr
, then it must be defined as an integer literal with value 0
(which is 0
, or 0L
, or something similar), which makes your code equivalent to char fullName[30] = {0};
.
This fills the array with zeroes, so Option B is the right answer.
In general, when you initialize an array with a brace-enclosed list, every element is initialized with something. If you provide fewer initializers than the number of elements, the remaining elements are zeroed.
Regarding the remaining options:
Option C is unclear, because if the code compiles, then NULL
is equivalent to 0
, so option C can be considered equivalent to Option B.
Option A can be valid depending on how you interpret it. If it means than the remaining elements are uninitialized, then it's wrong. If it doesn't specify what happens to the remaining elements, then it's a valid answer.
Option D is outright wrong, because arrays can't be "empty".
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…