Which part of the program address space is p stored in the code given below?
int *p = NULL;
int main()
{
int i = 0;
p = &i;
return 0;
}
Answer: B
Correct answer: Data segment
p is a file-scope variable with an explicit initialiser, so it goes in the data segment, which holds initialised statics and whose contents come from the executable file. (Strictly, a pointer initialised to NULL is all-zero and many toolchains put it in BSS after all; the distinction the question is drawing is between explicitly initialised and not.)
Please log in or register to report this question.