I am studying for an interview and found this question a bit bewildering. Would appreciate your advice.
What is not initialized by default?
- The last variable of a static array in which the first variables are explicitly initialized in a statement.
- Dynamic array members assigned using a
calloc
function.- Global variable.
- All data provided here is initialized by default.
- The current cursor location when a file is open.
- A static variable.
- The last character in a static character set.
I think the answer is #1 but not sure about the explanation.
calloc
zero the memory it points to.append
mode (a
infopen
) the cursor location will be 0. Inappend
mode it will be the length of the file.char
array, and like any other array, when initialized the lastchar
, if uninitialized, will be 0. In the case of achar
array, the lastchar
will be the NULL byte and its intention is to be 0 to mark the end of the string.As you can see, all the options are initialized by default so the answer is 4.
If you are not sure, always check your questions with a simple code: