C style

Bob Larson BLARSON%ECLD at usc-ecl.ARPA
Sun Oct 27 07:52:51 AEST 1985


Your examples are not equivelent, you forgot the "else result[i]=0;"
clause for every if on the nested example.  Besides, this example 
could be put as:

   for(i=0; i < 100 && checkreturn == GOOD; i++){
      if( (checkreturn = function1(x)) == GOOD &&
          (checkreturn = function2(x)) == GOOD &&
          (checkreturn = function3(x)) == GOOD &&
          (checkreturn = function4(x)) == GOOD &&
          (checkreturn = function5(x)) == GOOD )
        result[i]=function6(x);
      else result[i]=0;
   }

The if statement can be replaced by a ?: trianary operator.

Bob Larson 
Arpa: BLarson at usc-ecl.arpa
Uucp: ihnp4!sdcrdcf!oberon!blarson
-------



More information about the Comp.lang.c mailing list