Re: I need help please!



Bill Reid wrote, On 09/03/08 01:32:
Flash Gordon <spam@xxxxxxxxxxxxxxxxxx> wrote in message
news:mjkba5x7s8.ln2@xxxxxxxxxxxxxxxxxxxxxxxxxx
Bill Reid wrote, On 08/03/08 19:15:

<snip>

Richard Heathfield <rjh@xxxxxxxxxxxxxxx> wrote in message
<snip>

fgets(yn_input,sizeof(yn_input),stdin);
...this reply fails to check the result of a function that is very
likely
under some circumstances to fail.
OK, I like the wording "very likely under some circumstances"...are
THESE the circumstances (reading from the standard input) where
fgets() is "very likely" to fail? Awaiting your response...but yeah, I
acknowledge it COULD fail, possibly, maybe, and possibly maybe
I could make the library function even more "robust" in some way...any
PRACTICAL HELPFUL suggestions?...awaiting your response...
I sometimes forget which OS I'm using and press ctrl-z to try and
gracefully exit from a program, on some systems that would generate a
failure. I am a user as well as a programming by the way.

OK, THINK REAL HARD...I know this might be tough, but try...

YOU WANT TO "TRY" TO "GRACEFULLY" QUIT THE
PROGRAM BY PRESSING AN UNDOCUMENTED KEY
COMBINATION ABSENT-MINDEDLY, BUT YOU'RE WORRIED

It is documented on some systems I've use a lot as a standard way of exiting at any point.

ABOUT FAILURE TO GET A 'y' OR 'n' INPUT?

DOES THAT MAKE ANY SENSE? How about your untimely

<snip>

Any software written for general consumption should deal with unexpected keystrokes for the simple reason that, in the real world, they are very common.

fflush(stdin);
...and this demonstrates that the author either doesn't know what
fflush
does or doesn't know the difference between a stream open for output or
update and a stream open for input.
My compiler "does the right thing" for fflush(stdin) so I use it...sorry
about that, cheif, just did it to irritate you...oh wait, I just did it
(originally)
because IT WORKS AND I DON'T HAVE TO RE-INVENT THE WHEEL
TO SOLVE A PROBLEM THAT ONLY EXISTS ON THIS NEWSGROUP
AND NOT IN "REAL LIFE"...
It does not work on the machine I'm currently using. I know because I
just tested it. So it DOES NOT ALWAYS WORK IN REAL LIFE.

Next time you MIGHT try just reading the documentation (I know, that
doesn't ALWAYS work, but it's still the REASONABLE man's method
of discovering information about a system)...beats hitting the "any" key
to "test" stuff, anyway...

The point is that you claim that fflush(stdin) just works is wrong. The documentation would not have proved it as it does not mention flushing input streams, so I tested to enable me to state with certainty that it does not work. So you "REASONABLE man's method" fails on a very common system, namely Linux on an x86. I would say that a "solution" that does not work on a very common platform is NOT a reasonable solution.

<snip>

in the standard input...WOULD THAT MAKE YOU HAPPY, YOU
INSUFFERABLE TROLL??!!!?!!
So people who point out your mistakes are trolls. Hmm.

No, "snippy", people who use uncalled-for abusive and insulting
language to harass people who post well-meaning information are
trolls, but you "snipped" out the troll's nastiness for reasons known

OK, so you are a troll by your definition. That clears that up.

only to you...CONSTRUCTIVE criticism is ALWAYS welcome, but

So in your opinion any criticism of your posts is not constuctive, but posting bad advice is a good thing. Well, since you meet your definition of a troll this is not surprising.

please try to keep your disappointment down to a dull roar if I merely
point out that I've previously considered the point you've made and
rejected it on purely practical grounds for my purposes...

Simple enough?

So you want your software to rely on undefined behaviour that does not do what you expect on common platforms. The simple solution is to keep such software to yourself since it is not suitable for posting as advice and when you post it people will keep pointing out the problems with it.
--
Flash Gordon
.



Relevant Pages

  • Re: Pointer conversions
    ... Ioannis Vranos wrote: ... That's one of those things for which the standard defines no behavior, ... without any reason not to do define one. ... there is some implementation on which that fails, ...
    (comp.lang.c)
  • Re: Pointer conversions
    ... of those things for which the standard defines no behavior, ... reason not to do define one. ... some implementation on which that fails, I'd not object to it being ... but the one I'm using now appears to handle array ...
    (comp.lang.c)
  • Re: Coding inside the debugger
    ... but why isn't the test written so that the reason it fails is ... If something fails in tests like these, ... public void testCreateWithDefaultthrows Exception { ... Ghostworld world = worldWithClass; ...
    (comp.object)
  • build world build kernel correct order?
    ... i've been having nightmares building my kernel and world on a clean system: ... P4 celeron 128M freebsd5.1 standard no fluff integrated motherboard. ... buildkernel fails in either mode at the same point in the build. ... rerunning cvsup changes the spot that the build fails in. ...
    (freebsd-current)
  • Re: Malloc
    ... standard *could* have provided a method for getting a list of files ... is specific to Unix even though they are provided with Unix type ... I know of systems where opening a binary file in text mode fails. ...
    (comp.lang.c)