Consider the following program, where are i, j and k are stored in memory?
C
int i;
int main()
{
int j;
int *k = (int *) malloc (sizeof(int));
}
i, j and *k are stored in stack segment
i and j are stored in stack segment. *k is stored on heap.
i is stored in BSS part of data segment, j is stored in stack segment. *k is stored on heap.
j is stored in BSS part of data segment, i is stored in stack segment. *k is stored on heap.
This question is part of this quiz :
C Dynamic Memory Allocation