Path: utzoo!attcan!uunet!cs.utexas.edu!asuvax!ncar!mephisto!ncsuvx!news From: rcb@ccpv1.ncsu.edu (Randy Buckland) Newsgroups: comp.unix.wizards Subject: Re: Obscure code. Message-ID: <1990Mar28.131215.14795@ncsuvx.ncsu.edu> Date: 28 Mar 90 13:12:15 GMT References: <423@venice.SEDD.TRW.COM> Sender: news@ncsuvx.ncsu.edu (USENET News System) Organization: NCSU Computing Center Lines: 31 waldorf@venice.SEDD.TRW.COM (jerry waldorf) writes: >static int scanit(str, fmt, args) >register char *str; >char *fmt; >char **args; >{ > FILE _strbuf; > _strbuf._flag = _IOREAD | _IOSTRG; > _strbuf._ptr = _strbuf._base = (unsigned char *) str; > _strbuf._cnt = 0; > while(*str++) > _strbuf._cnt++; > _strbuf._bufsiz = _strbuf._cnt; > return(_doscan(&_strbuf, fmt, args)); >} > What exactly does this do and where do I find _doscan? _doscan is an internal routine of {scanf, fscnaf, sscanf}. This code is part of "sscanf". The doscan expects a FILE struct with a buffer already read in and will scan the chars in the buffer. scanf and fscanf call it with different arguments and for sscanf a fake FILE struct is built to allow it to call the same routine. _doscan will read the chars in the buffer (the passed string) and if that is not enough, will attempt to read more chars from the file. This will fail and doscan will return with what it has. Randy Buckland North Carolina State University (919) 737-2517 rcb@ccpv1.ncsu.edu