1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Returning pointer to local variable

Discussion in 'C' started by raviinroorkee_7, Nov 7, 2006.

Thread Status:
Not open for further replies.
  1. raviinroorkee_7

    raviinroorkee_7 New Member

    we should avoid returning a pointer to local variable. If one wants to do that then either variable has to be declared static or varable has to be allocated dynamically. In later case calling function should take care of deallocating the variable to avoid memory leaks.
    Can anyone tell me why it works in case of dynamically allocation and static declaration and why not in case of simple local variable?
  2. shabbir

    shabbir Administrator Staff Member

Thread Status:
Not open for further replies.

Share This Page