Article View: comp.os.msdos.programmer
Article #460Re: Borland C++ 3.0 scanf()/gets() bug.
From: Vanzandt
Date: Fri, 24 Jul 1992 11:31
Date: Fri, 24 Jul 1992 11:31
9 lines
861 bytes
861 bytes
I believe scanf only reads as much of the input as is needed to satisfy
the format string it has. The subsequent gets reads the rest of the line
(i.e. the \n). IMHO neither routine should ever be used. Instead, use
fgets to read a whole line (with protection against overrunning your
buffer), then sscanf to parse it.
- Jim Van Zandt <jrv@mbunix.mitre.org>
Technical Details
Message-ID:
<1992Jul24.113144.12779@linus.mitre.org>Path:
arc1-ca.pugleaf.net!sparky!uunet!sun-barr!ames!agate!linus!linus.mitre.org!truth!jrvReferences:
<1992Jul23.181820.29495@unixg.ubc.ca>Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!sun-barr!ames!agate!linus!linus.mitre.org!truth!jrv From: jrv@truth.uucp (Vanzandt) Subject: Re: Borland C++ 3.0 scanf()/gets() bug. Message-ID: <1992Jul24.113144.12779@linus.mitre.org> Sender: news@linus.mitre.org (News Service) Nntp-Posting-Host: truth.mitre.org Organization: The MITRE Corp., Bedford, Ma. References: <1992Jul23.181820.29495@unixg.ubc.ca> Date: Fri, 24 Jul 1992 11:31:44 GMT Lines: 10