Monday 8 April 2013

char *temp = “string constant";


char *someFun()
    {
    char *temp = “string constant";
    return temp;
    }
    int main()
    {
    puts(someFun());
    }
Answer:
    string constant
Explanation:
    The program suffers no problem and gives the output correctly because the character constants are stored in code/data area and not allocated in stack, so this doesn’t lead to dangling pointers.


Blog Author: Vijay Kumar

No comments:

Post a Comment