Originally Posted by
Prelude
Could you describe in detail what part of that code the book says is bad practice?
Sure! He wrote a program to divide two numbers like this:
Code:
#include <stdio.h>
void main(void) /* yes, he uses void main throughout the book! */
{
int a, b;
printf("Type two numbers: ");
scanf("%d%d", &a, &b);
if(b) printf("%d\n", a / b);
else printf("cannot divide by zero\n");
}
Right after this he wrote that if you write the if command this way,
Code:
if(b != 0) printf("%d\n", a / b);
it is redundant, possibly inefficient and bad style.