Date: Fri, 17 May 2002 20:27:04 +0300 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: djgpp AT delorie DOT com Message-Id: <3395-Fri17May2002202704+0300-eliz@is.elta.co.il> X-Mailer: emacs 21.2.50 (via feedmail 8 I) and Blat ver 1.8.9 In-reply-to: (noone@knowhere.com) Subject: Re: Static variables References: Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > From: "Matthew Bayliss" > Newsgroups: comp.os.msdos.djgpp > Date: Fri, 17 May 2002 17:03:03 +0100 > > If you break on line 117 and "print words_ptr" the pointer has an > assignment. When the function returns to main() (line 31) the variable has > no value. That's because C passes variables by value; if you want to change the variable's value, you need to pass its address. In this case, you want `inputdata' to change the value of the variable words_ptr, so you need to pass its address, like this: if ( inputdata( &words_ptr ) == 0 ) // Read the data in. Of course, the function's prototype should also change: int inputdata( struct wordstruct **words_ptr ); // Function to read words And the code of `inputdata' should change accordingly as well.