Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | "BartC" <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: scanf() |
| Date | 2012-08-11 23:04 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <k06kui$q2t$1@dont-email.me> (permalink) |
| References | (2 earlier) <jvrn8u$2df$1@speranza.aioe.org> <aae1aae8-8665-4d38-8273-fe5c24c52133@googlegroups.com> <13a134c9-5a13-4ad8-a59d-227aa68e94c3@googlegroups.com> <ln1ujduy1j.fsf@nuthaus.mib.org> <7337238e-c54d-496a-a29f-c96799218e81@googlegroups.com> |
"Malcolm McLean" <malcolm.mclean5@btinternet.com> wrote in message news:7337238e-c54d-496a-a29f-c96799218e81@googlegroups.com... > בתאריך יום שבת, 11 באוגוסט 2012 18:40:56 UTC+1, מאת Keith Thompson: >> Malcolm McLean <malcolm.mclean5@btinternet.com> writes: >> >> There are worse possibilities than wrong results. If the input includes >> something like "1.0e999999999", the behavior is undefined. >> > But what is the program meant to do with such an input value? UB is > probably the > best thing that can happen to it. > "Undefined behaviour" means "the C standard imposes no restrictions on the > behaviour of the implementation", not that the behaviour exists in some > ontological state of undefinedness. So, you have an application which consists of a user interface and a bunch of data, much of which has not been committed to disk. It's been running for several hours, but if the user then chooses a command which reads something from a file, and accidentally chooses a binary instead of a text file, the application should just crash with the loss of all data? You've obviously never had to deal with irate clients on the phone! (With the routines I use (the C stuff is buried several layers deep so I couldn't tell you exactly what library functions are used), any non-numeric input will return 0.0 when trying to read floating point. Anything numeric but out-of-range such as 1.0e99999999 is read as INF. Input is always line oriented too (so running into end-of-line while trying to read more numbers will just return 0.0. All solid behaviour, although it's possible some of this is due to a well-behaved version of scanf() somewhere.) -- Bartc
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
scanf() Edward Rutherford <edward.p.rutherford79@REMOVETHIS.gmail.com> - 2012-08-06 20:58 +0000
Re: scanf() Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-08-06 17:29 -0400
Re: scanf() Keith Thompson <kst-u@mib.org> - 2012-08-06 14:40 -0700
Re: scanf() James Kuyper <jameskuyper@verizon.net> - 2012-08-06 17:39 -0400
Re: scanf() Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-08-06 22:49 +0100
Re: scanf() Edward Rutherford <edward.p.rutherford79@REMOVETHIS.gmail.com> - 2012-08-07 18:37 +0000
Re: scanf() James Kuyper <jameskuyper@verizon.net> - 2012-08-07 15:01 -0400
Re: scanf() Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-08-07 15:03 -0400
Re: scanf() Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-08-07 20:51 +0100
Re: scanf() John Bode <jfbode1029@gmail.com> - 2012-08-09 14:00 -0700
Re: scanf() Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-08-11 03:08 -0700
Re: scanf() Keith Thompson <kst-u@mib.org> - 2012-08-11 10:40 -0700
Re: scanf() Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-08-11 13:34 -0700
Re: scanf() "BartC" <bc@freeuk.com> - 2012-08-11 23:04 +0100
Re: scanf() James Kuyper <jameskuyper@verizon.net> - 2012-08-11 19:20 -0400
Re: scanf() Keith Thompson <kst-u@mib.org> - 2012-08-11 17:30 -0700
Re: scanf() Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-08-11 20:41 -0400
Re: scanf() Keith Thompson <kst-u@mib.org> - 2012-08-11 18:13 -0700
Re: scanf() Keith Thompson <kst-u@mib.org> - 2012-08-11 18:16 -0700
Re: scanf() Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-08-11 21:32 -0400
Re: scanf() Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-08-12 04:07 -0700
Re: scanf() James Kuyper <jameskuyper@verizon.net> - 2012-08-12 08:03 -0400
Re: scanf() Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-08-12 06:41 -0700
Re: scanf() Keith Thompson <kst-u@mib.org> - 2012-08-12 13:39 -0700
Re: scanf() Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-08-12 14:20 -0700
Re: scanf() Keith Thompson <kst-u@mib.org> - 2012-08-12 16:33 -0700
Re: scanf() "Heinrich Wolf" <invalid@invalid.invalid> - 2012-08-13 12:22 +0200
Re: scanf() Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-09-05 00:13 +0300
Re: scanf() Tim Rentsch <txr@alumni.caltech.edu> - 2012-09-07 14:18 -0700
Re: scanf() Keith Thompson <kst-u@mib.org> - 2012-09-07 15:02 -0700
Re: scanf() Tim Rentsch <txr@alumni.caltech.edu> - 2012-09-07 17:25 -0700
Re: scanf() Keith Thompson <kst-u@mib.org> - 2012-09-07 18:35 -0700
Re: scanf() Seungbeom Kim <musiphil@bawi.org> - 2012-08-12 21:05 -0700
Re: scanf() Robert Wessel <robertwessel2@yahoo.com> - 2012-08-11 17:37 -0500
csiph-web