Re: for loop problem
- From: Richard <rgrdev_@xxxxxxxxx>
- Date: Thu, 16 Apr 2009 02:57:37 +0200
CBFalconer <cbfalconer@xxxxxxxxx> writes:
Richard Heathfield wrote:
CBFalconer said:... snip ...
Unique in the sense that, while the extended ability may be
copied, its specification will not be, and thus the ability MAY
perform differently. For example, I often use and recommend:
int flushln(FILE *f) {
int ch;
while ((EOF != (ch = getc(f))) && ('\n' !- ch)) continue;
return ch;
}
gcc chokes big-time on this until I add #include <stdio.h>, which is
fair enough. But then it *still* chokes. Presumably you intended to
write != rather than !- but of course the compiler doesn't know
that.
Yes, that is a valid correction. You have saved many users.
Please TEST your code before posting. You would then save a lot of
people yourself. Having the unnecessary continue also deflects from
noticing the error of course and why I in over 20 years of programming I
have never known anyone use it for that use in C.
while ((EOF != (ch = getc(f))) && ('\n' != ch));
is better but still horrible. You have a habit or tendency to convolute
your code. This is C. C can and should be concise.
while (((ch=getc(f))!=EOF)&&(ch!='\n'));
Is even clearer and reads properly left to right. I find it particularly
amusing that your pathetic defence of the " CONST == var" style is to
defend against "accidentally" using "=" instead of "==" and yet you
still fucked it up. Nice one. A real achievement.
Normally one would not comment on silly little errors but you bring it
on yourself you condescending arse.
... snip about 150 lines of spouting ...
Or someone can use the same code and name it "lineflush", etc.
Or they could choose a good name that reflects the purpose of
the function.
I don't recall requesting that 150 odd lines of spouting about your
language choice peculiarities. Snipping it will probably reduce
the excess traffic on this newsgroup.
--
"Avoid hyperbole at all costs, its the most destructive argument on
the planet" - Mark McIntyre in comp.lang.c
.
- Follow-Ups:
- Re: for loop problem
- From: nick_keighley_nospam
- Re: for loop problem
- From: luserXtrog
- Re: for loop problem
- References:
- for loop problem
- From: chen_li3
- Re: for loop problem
- From: BartC
- Re: for loop problem
- From: chen_li3
- Re: for loop problem
- From: CBFalconer
- Re: for loop problem
- From: BartC
- Re: for loop problem
- From: CBFalconer
- Re: for loop problem
- From: Willem
- Re: for loop problem
- From: CBFalconer
- Re: for loop problem
- From: Richard Heathfield
- Re: for loop problem
- From: CBFalconer
- for loop problem
- Prev by Date: A scope problem??
- Next by Date: Re: Portability regarding sizeof() function
- Previous by thread: Re: for loop problem
- Next by thread: Re: for loop problem
- Index(es):