×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
On 2014-04-02 02:32, frank kolmann wrote:
...
1. Don't use = in an if statement expression, unless it is
absolutely necessary.
Frank, this code seems to violate that guideline.
if ((pf = _Ropen(PFILENAME, "rr")) EQ NULL)
{ printf("can't open file %s\n", PFILENAME); exit(1); }
I think it's a very good guideline. I would code that like this. (I'll
go along with the EQ ...)
pf = _Ropen(PFILENAME, "rr");
if (pf EQ NULL)
...
I would also spread out the code under the "if". I think it's too easy
to miss the exit statement when the printf and exit are on the same line.
I also think it's easier to see exactly what code is conditioned by the
"if" when the curly braces are coded on their own lines.
pf = _Ropen(PFILENAME, "rr");
if (pf EQ NULL)
{
printf("can't open file %s\n", PFILENAME);
exit(1);
}
This code takes up a few more lines than yours, but I find it much more
readable-at-a-glance. If you want to collapse the code to make it easier
to follow the whole program, you could put all the opens into a separate
function.
As an Amazon Associate we earn from qualifying purchases.