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
callocfunction.- 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.
calloczero the memory it points to.appendmode (ainfopen) the cursor location will be 0. Inappendmode it will be the length of the file.chararray, and like any other array, when initialized the lastchar, if uninitialized, will be 0. In the case of achararray, the lastcharwill 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: