User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 391,785 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,558 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser:

Pointers == NULL upon function return?

Join Date: Apr 2006
Location: Canada
Posts: 4,446
Reputation: John A is a glorious beacon of light John A is a glorious beacon of light John A is a glorious beacon of light John A is a glorious beacon of light John A is a glorious beacon of light 
Rep Power: 15
Solved Threads: 265
Moderator
Staff Writer
Featured Blogger
John A's Avatar
John A John A is offline Offline
Vampirical Moderator

Re: Pointers == NULL upon function return?

  #2  
May 8th, 2008
That's because the memory address contained in the pointer is lost when the function is popped off the stack. In other words, you can modify the value that the pointer points to, but you can't modify the memory address that the pointer holds (well, you can, but the change won't have any effect on the pointer in the parent function).

The solution to this would be to use a pointer of a pointer.
Last edited by John A : May 8th, 2008 at 6:35 pm.
tuxation.com - Linux articles, tutorials, and discussions
Reply With Quote  
All times are GMT -4. The time now is 5:03 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC