From: "Richard Damon" To: Subject: RE: Static variables Date: Fri, 17 May 2002 14:12:56 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 In-Reply-To: Importance: Normal 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 > -----Original Message----- > From: Matthew Bayliss [mailto:noone AT knowhere DOT com] > Sent: Friday, May 17, 2002 12:03 PM > To: djgpp AT delorie DOT com > Subject: Static variables > > > I have a variable declared outside of main() with a static keyword. > > 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. > > Why is this? I thought a static variable would also keep it's > value between > funtions. > > Help. ...snip... > static struct wordstruct *words_ptr; ...snip... > int inputdata( struct wordstruct *words_ptr ) > { ...snip... > } > Inside the function inputdata the parameter words_ptr will hide the global words_ptr. Since it seams you want the global variable, make inputdata have no parameters and just use the global. Richard Damon -- rbrdamon AT rcn DOT com (Home) rdamon AT beltronicsinc DOT com (Work)