Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!leah!itsgw!steinmetz!uunet!mcvax!jack From: jack@cwi.nl (Jack Jansen) Newsgroups: comp.bugs.4bsd Subject: Re: ungetc will put characters back into an _IOSTRG input stream Keywords: writable strings, shared strings (text segment), sscanf, ungetc Message-ID: <7898@boring.cwi.nl> Date: 13 Feb 89 23:10:12 GMT References: <20282@lll-winken.LLNL.GOV> Sender: news@cwi.nl Organization: AMOEBA project, CWI, Amsterdam Lines: 12 I ran into this problem as well, some time ago. My fix was to have ungetc() only push the character back if it isn't there already, i.e. if( *--fp->_ptr != ch ) *fp->_ptr = ch; Makes sscanf work with read-only strings, and still keeps the semantics the same. -- -- Fight war, not wars | Jack Jansen, jack@cwi.nl Destroy power, not people! -- Crass | (or mcvax!jack)