p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

c_plus_plus_programming thread: Re: Variable is loosing its value b/w function calls


Message #1 by Drew <dwskp@y...> on Mon, 11 Feb 2002 22:34:44 -0800 (PST)
Hey,



 Could you show what you're trying to do with a piece of code? It would

be easier to help that way, but sounds like you may have a pointer

problem. 



 I may not know exactly what you're trying to do, but if you're trying

to do what I'm thinking you are than try this:



char* error = (&myError);

//do something

delete error;

error = 0;



Const* char (char variable){

   char* someChar = new char[0];

   someChar = &variable; 

   return someChar;

}

 

 and don't forget to deallocate the memory on the heap by calling

 delete Ptr after you're done with it

---

 lates,

 Drew Wilson







--- prakashnmurthy <prakashnmurthy@i...> wrote:

> Hi All,

> 

> 

> I am Passing a    Const char * (some variable) to a function.

> 

> 

> In the called function I am recieving it through Errmsg

> 

> 

> where  Errmsg is char * Errmsg

> 

> 

>  

> 

> 

> Again this Errmsg I am passing it to some other function as Errmsg.

> 

> 

> Where in the called function its been recieved as const char* Errcode

> 

> 

>  

> 

> 

> all these functions are in the same file and in the last function

> where I am recieving it in Errcode is a static function.

> 

> 

> My problem is.. Once after calling my functions if I see the value

> inside Errcode.. it is showing NULL. Please note that I am not

> modifying it anywhere across the functions.

> 

> 

> Can anyone tell me why is this happening

> 

> 

> Regards

> 

> 

> Prakash

> Get Your Private, Free E-mail from Indiatimes at 

> http://email.indiatimes.com

> Buy Music, Video, CD-ROM, Audio-Books and Music Accessories from

> http://www.planetm.co.in

> 

> 




> $subst('Email.Unsub').

> 





__________________________________________________

Do You Yahoo!?

Send FREE Valentine eCards with Yahoo! Greetings!

http://greetings.yahoo.com


  Return to Index