Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > I need help please!

Reply
Thread Tools

I need help please!

 
 
Bill Reid
Guest
Posts: n/a
 
      03-08-2008

BWHAHAHAHAHAHAHAHAHA!!!!

And to think, I came this close to complimenting you on your helpful,
knowledgeable, and correct answer to to the question about "Calling
external function in C"...the exception that proves the rule, I reckon, and
certainly a RARE event...

Richard Heathfield <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Bill Reid said:
>
> > I shouldn't be doing your homework for you...

>
> Right. Quite apart from the morality issue (and I haven't read the OP
> closely enough to determine whether that /is/ an issue in this case)...
>

It was...

> > 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...

> What's more, it attempts to populate a
> non-existent array...


Nahhh, it exists, just not locally...sorry about that, cheif, just did it
to irritate you...I also acknowleged there's a whole bunch of stuff that
you have to assume exists, but you must have missed that part of
my post since it was in plain simple English...

> <snip>
>
> > 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"...

But OK, we can replace the above with a call to another function
called "clear_input()" or something that, depending on the compiler,
either calls fflush(stdin) (I guess the waste of the calling overhead
can be ignored due to the inherent "user wait" involved in what
we're doing) or a routine to chew up all the garbage characters
in the standard input...WOULD THAT MAKE YOU HAPPY, YOU
INSUFFERABLE TROLL??!!!?!!

Or is the existence of working, practical computer code on the
face of this planet (hate to tell you this, it's out there, not in great
quantities compared to the number of "programmers" like you, but
it exists) such a threat to you that you will spend the rest of your
miserable life in a blue funk?

> I can't help wondering whether, when the author of this code was at
> college, someone else did /his/ homework.


Well, I didn't take any computer science classes (the closest I got
was Boolean algebra and sentential logic), but actually I occasionally
did OTHER people's homework if the price was right...it was "morally"
wrong, I know, but even worse, I keep running into the same TYPE
of people now (idiotic cheaters) and they make a LOT more money
than I do and are highly-ranked "respected" business "leaders", which,
"morality" aside, I guess just proves something about people in general,
it's up to the reader to decide what...

---
William Ernest Reid



 
Reply With Quote
 
 
 
 
santosh
Guest
Posts: n/a
 
      03-08-2008
Bill Reid wrote:

[ ... ]

> Richard Heathfield <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Bill Reid said:


[ ... ]

>> > 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? [ ... ]


It can fail when the operator sends the end-of-file sequence (CONTROL-D
for UNIX, CONTROL-Z for Windows/DOS/CP-M). Surely you want to handle
this?

>> <snip>
>>
>> > 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...


> Or is the existence of working, practical computer code on the
> face of this planet (hate to tell you this, it's out there, not in
> great quantities compared to the number of "programmers" like you, but
> it exists) such a threat to you that you will spend the rest of your
> miserable life in a blue funk?


But you should at least have mentioned to the OP that fflush(stdin) is
not portable. Subtly misleading advice is sometimes worse than an
outright wrong one.

<snip>

 
Reply With Quote
 
 
 
 
Bill Reid
Guest
Posts: n/a
 
      03-08-2008

santosh <(E-Mail Removed)> wrote in message
news:fqup8v$db5$(E-Mail Removed)...
> Bill Reid wrote:
>
> [ ... ]
>
> > Richard Heathfield <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >> Bill Reid said:

>
> [ ... ]
>
> >> > 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? [ ... ]

>
> It can fail when the operator sends the end-of-file sequence (CONTROL-D
> for UNIX, CONTROL-Z for Windows/DOS/CP-M). Surely you want to handle
> this?


Thanks for proving my point, although "troll zero"'s non-response
also serves the same purpose.

No, handling THAT is not high on my list of priorities, because obviously
it is highly UNLIKELY that a user, after being prompted to press either
'y' or 'n' is going to simultaneously press CTRL and 'd' or 'z'. We COULD
test the probability of that happening empirally by placing cats on
keyboards,
and record how many hundreds of cats over how many thousands of
years it takes to get a statistically significant number of failures.

But I guess in the history of the universe it will happen a few times,
so if I acquire several hundred cats crammed into my home office that
I allow to walk over my keyboard after I have started one of my programs
apparently only for the purpose of allowing cats to crash it, I will be sure
to check the return value of fgets() and handle it "appropriately"...

> >> <snip>
> >>
> >> > 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...

>
> > Or is the existence of working, practical computer code on the
> > face of this planet (hate to tell you this, it's out there, not in
> > great quantities compared to the number of "programmers" like you, but
> > it exists) such a threat to you that you will spend the rest of your
> > miserable life in a blue funk?

>
> But you should at least have mentioned to the OP that fflush(stdin) is
> not portable. Subtly misleading advice is sometimes worse than an
> outright wrong one.


I said that I assumed that the OP is long gone, since I posted well
AFTER his four-hour window of opportunity for getting somebody to
do his homework for him. The remaining audience for the post then
largely consists of people who a) know that call is "non-portable" and
b) know that MANY compilers on MANY systems provide it but
c) never tire of the "fun" of pointing out it is "non-portable" in insulting
and abusive language despite the fact just about everybody reading
the post knows the exact status of the call.

---
William Ernest Reid



 
Reply With Quote
 
santosh
Guest
Posts: n/a
 
      03-08-2008
Bill Reid wrote:

>
> santosh <(E-Mail Removed)> wrote in message
> news:fqup8v$db5$(E-Mail Removed)...
>> Bill Reid wrote:
>>
>> [ ... ]
>>
>> > Richard Heathfield <(E-Mail Removed)> wrote in message
>> > news:(E-Mail Removed)...
>> >> Bill Reid said:

>>
>> [ ... ]
>>
>> >> > 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? [ ... ]

>>
>> It can fail when the operator sends the end-of-file sequence
>> (CONTROL-D for UNIX, CONTROL-Z for Windows/DOS/CP-M). Surely you want
>> to handle this?

>
> Thanks for proving my point, although "troll zero"'s non-response
> also serves the same purpose.
>
> No, handling THAT is not high on my list of priorities, because
> obviously it is highly UNLIKELY that a user, after being prompted to
> press either 'y' or 'n' is going to simultaneously press CTRL and 'd'
> or 'z'. We COULD test the probability of that happening empirally by
> placing cats on keyboards, and record how many hundreds of cats over
> how many thousands of years it takes to get a statistically
> significant number of failures.


A library routine must try to deal sensibly with all reasonable
possibilities. CTRL-D is often used to signal end of input, or as a
wish to exit from the program. That is another option that you should
try to present, wherever it makes sense: allowing a user to exit the
application without having to kill it with CTRL-C or 'kill'.

<snip>

Regarding the fflush(stdin) call in your code, you might have considered
mentioning it's non-portability for the benefit of other newbies that
might be lurking, not just for the OP. It's used too often everywhere,
without people knowing that it invokes undefined behaviour on anything
other than output streams and update streams where the most recent
operation was output. You also fail to check for the possibility of
fflush failing.

 
Reply With Quote
 
Flash Gordon
Guest
Posts: n/a
 
      03-08-2008
Bill Reid wrote, On 08/03/08 19:15:

<snip>

> Richard Heathfield <(E-Mail Removed)> 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.

<snip>

>>> 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.

<snip>

> in the standard input...WOULD THAT MAKE YOU HAPPY, YOU
> INSUFFERABLE TROLL??!!!?!!


So people who point out your mistakes are trolls. Hmm.
--
Flash Gordon
 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      03-09-2008
Bill Reid wrote:
>

.... snip ...
>
> I said that I assumed that the OP is long gone, since I posted well
> AFTER his four-hour window of opportunity for getting somebody to
> do his homework for him. The remaining audience for the post then
> largely consists of people who a) know that call is "non-portable"
> and b) know that MANY compilers on MANY systems provide it but
> c) never tire of the "fun" of pointing out it is "non-portable" in
> insulting and abusive language despite the fact just about everybody
> reading the post knows the exact status of the call.


No, the majority of educated users in this group KNOW that some
things are not guaranteed by the C standard, and thus should be
avoided. They find that the simple action of using the library and
language correctly ensures the portability of their code. They are
extremely lazy, and do not eagerly anticipate rewriting all their
code at every port.

You are lucky enough to get their analysis without charge. If you
choose to ignore it, that's your loss. But insulting those helpful
and knowledgeable people tends to get you ignored.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.



--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      03-09-2008
Flash Gordon wrote:
> Bill Reid wrote, On 08/03/08 19:15:
>

.... snip ...
>
>> 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.
>
> <snip>
>
>> in the standard input...WOULD THAT MAKE YOU HAPPY, YOU
>> INSUFFERABLE TROLL??!!!?!!

>
> So people who point out your mistakes are trolls. Hmm.


I think 'Bill Reid' just earned a PLONK.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.



--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
Bill Reid
Guest
Posts: n/a
 
      03-09-2008

Flash Gordon <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)-gordon.me.uk...
> Bill Reid wrote, On 08/03/08 19:15:
>
> <snip>
>
> > Richard Heathfield <(E-Mail Removed)> 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
ABOUT FAILURE TO GET A 'y' OR 'n' INPUT?

DOES THAT MAKE ANY SENSE? How about your untimely
death at the keyboard with your cheek hitting CTRL and your nose
hitting 'z'?

You know what else I haven't stupidly allowed for...you suddenly
decide you are giving up on modern technology when confronted
with a 'y' or 'n' input prompt, so you take a sledgehammer to your
computer and smash it to bits!!! WHAT HAPPENS IF I DON'T
CHECK THE RETURN VALUE OF fgets() IN THAT "VERY LIKELY
UNDER CERTAIN CIRCUMSTANCES" SITUATION!!??!!

You're right, there's so much I haven't taken into account...giant
asteroids, the return of disco music, electromagnetic pulses sending
the keyboard into a parallel universe...HEP ME LEST I CODE AGAIN!!!

> <snip>
>
> >>> 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...

> <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
only to you...CONSTRUCTIVE criticism is ALWAYS welcome, but
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?

---
William Ernest Reid



 
Reply With Quote
 
Bill Reid
Guest
Posts: n/a
 
      03-09-2008

santosh <(E-Mail Removed)> wrote in message
news:fqusqh$o1$(E-Mail Removed)...
> Bill Reid wrote:
>
> >
> > santosh <(E-Mail Removed)> wrote in message
> > news:fqup8v$db5$(E-Mail Removed)...
> >> Bill Reid wrote:
> >>
> >> [ ... ]
> >>
> >> > Richard Heathfield <(E-Mail Removed)> wrote in message
> >> > news:(E-Mail Removed)...
> >> >> Bill Reid said:
> >>
> >> [ ... ]
> >>
> >> >> > 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? [ ... ]
> >>
> >> It can fail when the operator sends the end-of-file sequence
> >> (CONTROL-D for UNIX, CONTROL-Z for Windows/DOS/CP-M). Surely you want
> >> to handle this?

> >
> > Thanks for proving my point, although "troll zero"'s non-response
> > also serves the same purpose.
> >
> > No, handling THAT is not high on my list of priorities, because
> > obviously it is highly UNLIKELY that a user, after being prompted to
> > press either 'y' or 'n' is going to simultaneously press CTRL and 'd'
> > or 'z'. We COULD test the probability of that happening empirally by
> > placing cats on keyboards, and record how many hundreds of cats over
> > how many thousands of years it takes to get a statistically
> > significant number of failures.

>
> A library routine must try to deal sensibly with all reasonable
> possibilities. CTRL-D is often used to signal end of input, or as a
> wish to exit from the program. That is another option that you should
> try to present, wherever it makes sense: allowing a user to exit the
> application without having to kill it with CTRL-C or 'kill'.


Well, my "user" is me, and me alone, as I've said many times, and
I know exactly how and when to exit the application (as a matter of
fact, generally you are offered the option to "abort" in all menus,
which is usually a RETURN default that bumps you back to a previous
level menu, so press RETURN about three or four times tops and you're
done)...so MY library deals with all MY reasonable possibilities, so
it's "golden" by your "standard"...

In short, the routine works for ME...for others, a few tweaks may be in
order...

> <snip>
>
> Regarding the fflush(stdin) call in your code, you might have considered
> mentioning it's non-portability for the benefit of other newbies that
> might be lurking, not just for the OP. It's used too often everywhere,
> without people knowing that it invokes undefined behaviour


I suspect that in many cases, people use it simply because it's
DOCUMENTED in their compiler documentation, but OK, in the past
when I've shown code with fflush(stdin) I've mentioned it was
"non-portable", but in this case I SPECIFICALLY said I wasn't going
to exhaustively "mention" all the OTHER "non-portabilities" in the
code, I just wanted to freakin' cut'n'paste it and let it go, BUT NOOOOO,
that can't happen HERE...

> on anything
> other than output streams and update streams where the most recent
> operation was output. You also fail to check for the possibility of
> fflush failing.


OK, I give up, now I forgot to check the return value of fflush(whatever),
but you know what? The code is there, it has a goal, it could be made
even "better", have at it and re-post it when it's perfect...but then we
ALL know some prig will get all freaked-out by the "goto"s or something
else AND IT NEVER ENDS DOES IT?!!??!!

Of course, for me it also never ends as well, but I'm willing to let
stuff go when it's "good enough" in the interest of just GETTING
SOME STUFF DONE, which I stated as the goal of the whole thing
in the first place...here I am, making all these mistakes, and yet
I'm churning out great gobs of useful program functionality with
automatically-generated dual interfaces without worrying about
writing menus and prompts and dialog boxes and stupid crap like
that, so I'm happy, why can't you be happy for me?

---
William Ernest Reid



 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      03-09-2008
Bill Reid wrote:
> Richard Heathfield <(E-Mail Removed)> wrote:
>> Bill Reid said:
>>
>>> 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"...
>

The compiler has little to do with it, it works with any compiler on a
platform where the operation is defined and fails with any platform
where its isn't.

Such platform specific code is pretty common (I know I've used
fflush(stdin) on Solaris), but is should be noted, or even conditionally
compiled as a hint for maintainers. The maintainer might be you
porting your own code to a new platform.

--
Ian Collins.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Help, I am intermediate in Java...need help in follow case ElementX Java 9 10-01-2008 08:02 PM
Help Help. I really need some help with this =?Utf-8?B?Q2hyaXM=?= ASP .Net 3 01-31-2007 09:33 PM
re_---need help Network Adapters!!!! NEED HELP!!!! hedayatniac@gmail.com Computer Support 4 08-13-2006 01:03 AM
Need help! I need to add lead zeros to a textbox Teep ASP .Net 2 06-21-2004 01:04 PM
Please help!!! Need datagrid selection to fill textboxes...Need quick!! TN Bella ASP .Net 1 06-18-2004 01:31 AM



Advertisments