Path: 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 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().