none
Regarding memory allocation

    Question

  • If declare a local pointer like char *ptr="Sunil"; From where the memory is allocated to ptr? Is it from heap or stack?
    Monday, May 30, 2016 6:13 AM

Answers

  • >If declare a local pointer like char *ptr="Sunil"; From where the memory is allocated to ptr? Is it from heap or stack?

    Neither.

    The characters for the string "Sunil" will exist in either the code or
    data segment (depending on the compiler & build options).

    The ptr variable memory will normally be on the stack if ptr is a
    local variable of a function.

    Dave

    Monday, May 30, 2016 8:11 AM