🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1086

Re: Hints for using "scanf" (was Re: ... scanf interpretation question(s))

#1086
From: Doug Gwyn
Date: Wed, 17 Jan 1990 13:55
13 lines
1151 bytes
In article <583@mwtech.UUCP> martin@mwtech.UUCP (Martin Weitzel) writes:
>If you want to analyze interactive (or unpredictable) input,
>my advice is to read a complete line with "fgets" (avoid "gets"!!)
>or read up to some other significant token with "gets/fgets".
>After that, use "sscanf" on the buffer you just read.

Yes, this is much cleaner than using fscanf().  You can also use
some of the str*() functions instead of or in addition to sscanf()
to parse the buffer.

Many X3J11 members disliked including *scanf() in the Standard, but
because it was widespread existing practice we had to do it.  Same
for gets().
Technical Details
Message-ID: <11965@smoke.BRL.MIL>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!purdue!haven!adm!smoke!gwyn
References: <21624@mimsy.umd.edu> <21625@mimsy.umd.edu> <11881@smoke.BRL.MIL> <583@mwtech.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!purdue!haven!adm!smoke!gwyn
From: gwyn@smoke.BRL.MIL (Doug Gwyn)
Newsgroups: comp.std.c
Subject: Re: Hints for using "scanf" (was Re: ... scanf interpretation question(s))
Message-ID: <11965@smoke.BRL.MIL>
Date: 17 Jan 90 13:55:39 GMT
References: <21624@mimsy.umd.edu> <21625@mimsy.umd.edu> <11881@smoke.BRL.MIL> <583@mwtech.UUCP>
Reply-To: gwyn@brl.arpa (Doug Gwyn)
Organization: Ballistic Research Lab (BRL), APG, MD.
Lines: 13