Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!pt.cs.cmu.edu!b.gp.cs.cmu.edu!Ralf.Brown@B.GP.CS.CMU.EDU From: Ralf.Brown@B.GP.CS.CMU.EDU Newsgroups: comp.sys.ibm.pc Subject: Re: TC function returns rubbish. why? Message-ID: <257e58e2@ralf> Date: 7 Dec 89 11:34:42 GMT Sender: ralf@b.gp.cs.cmu.edu Organization: Carnegie Mellon University School of Computer Science Lines: 23 In-Reply-To: <272@cica.cica.indiana.edu> In article <272@cica.cica.indiana.edu>, burleigh@cica.cica.indiana.edu (Frank Burleigh) wrote: >char *make_fn( char * file_name ) >{ > char name[13]; > > return name; >} >make_fn, but when we get back to mark_cmp, the string has >been destroyed. You may see only part of the name followed That's because you are returning the address of a variable which ceases to exist as soon as you leave the function. What you need is static char name[13] ; -- UUCP: {ucbvax,harvard}!cs.cmu.edu!ralf -=-=-=-=- Voice: (412) 268-3053 (school) ARPA: ralf@cs.cmu.edu BIT: ralf%cs.cmu.edu@CMUCCVMA FIDO: Ralf Brown 1:129/46 FAX: available on request Disclaimer? I claimed something? "How to Prove It" by Dana Angluin 13. proof by reference to inaccessible literature: The author cites a simple corollary of a theorem to be found in a privately circulated memoir of the Slovenian Philological Society, 1883.