Message-ID: <001901be6d5b$3fee83c0$195d44ce@computer> From: "Sean Middleditch" To: Subject: Re: Passing/updating pointers... Date: Sat, 13 Mar 1999 09:10:27 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3110.1 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Reply-To: djgpp AT delorie DOT com I'm not exactly sure what you mean, but what I think you're trying to say is that you need to change the address pointed to by the pointer passed as an argument to a function... void ChangeString ( char *Str ) { Str = SomethingElse; } In which the value of Str changes. To do this, pass a pointer to a pointer: void ChangeString ( char **Str ) { *Str = SomethingElse; } And when you call the function, pass the address of the pointer: int main ( void ) { char *String = "Some Text"; ChangeString ( &Str ); } Hope I could help. Sean Middleditch of AwesomePlay Productions http://www.angelfire.com/biz/aweplay aweplay AT iname DOT com -----Original Message----- From: Thomas J. Hruska Newsgroups: comp.os.msdos.djgpp To: djgpp AT delorie DOT com ; buzdor AT email DOT com Date: Saturday, March 13, 1999 1:50 AM Subject: Passing/updating pointers... >I have never quite figured out how to pass a pointer to a function and have >the function update the variable sent to it. So, for many years I have >just found ways to work around this little glitch in my memory. Now, I >have come to a point in a program that I'm writing where I can't work >around the problem anymore. > >Here is what I want to do: > >// Read a line of text from buffer in memory and return string >char *LineInput(char *src) >{ > char *dest, src2; > > src2 = src; >.. > [update input pointer (src) with src2] > return dest; >} > >So, how would I go about doing this? That is, how would I call the >function and how would I perform the update? > > > Thomas J. Hruska -- shinelight AT detroit DOT crosswinds DOT net >Shining Light Productions -- "Meeting the needs of fellow programmers" > http://www.geocities.com/SiliconValley/Heights/8504 > http://click-on.to/shinelight > >