Re: [re-post] why no output
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Fri, 15 May 2009 08:28:33 -0700
James Kuyper <jameskuyper@xxxxxxxxxxx> writes:
Franken Sense wrote:
In Dread Ink, the Grave Hand of Mark McIntyre Did Inscribe:
On 14/05/09 05:58, Franken Sense wrote:
This compiles. Why no output?....
int main(void)....
{
while((len = get_script(fp, text, NUMBER))> 0)why are you comparing a bool to zero?
Surely you want to loop while get_script is returning
data. Currently it loops as long as false > 0. Is it?
I thought it would work since 1 > 0.
But if you're bothering to declare it as returning bool rather than
int, and if all of your return statements use either true or false,
you should be comparing its return value with true or false, rather
than numeric values. This is purely a style issue; but then so is the
use of bool in the first place.
No, you should never declare a boolean value to true or false. Just
test the value.
Rather than "if (cond == true)", just write "if (cond)".
Rather than "if (cond == false)", just write "if (!cond)".
(But "len" is an odd name for a boolean anyway.)
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.
- Follow-Ups:
- Re: [re-post] why no output
- From: jameskuyper
- Re: [re-post] why no output
- References:
- [re-post] why no output
- From: Franken Sense
- Re: [re-post] why no output
- From: Mark McIntyre
- Re: [re-post] why no output
- From: Franken Sense
- Re: [re-post] why no output
- From: James Kuyper
- [re-post] why no output
- Prev by Date: Re: comma operator
- Next by Date: Re: comma operator
- Previous by thread: Re: [re-post] why no output
- Next by thread: Re: [re-post] why no output
- Index(es):
Relevant Pages
|