Reply to jeff at isi-vaxa
G.R.Tomasevich
grt at twitch.UUCP
Tue Aug 26 22:10:21 AEST 1986
The mail failed with some long reply I don't understand.
< if (
< ( (status = step_1()) == SUCCESS) &&
< ( (status = step_2()) == SUCCESS) &&
< .
< .
< .
< ( (status = step_3()) == SUCCESS)
< );
One way to avoid this is to store the pointers to the functions step_?()
in an array and then run a for() loop with a break on failure. E. g.:
int step_1(), step_2() ...;
int (*fst[])() = { step_1, step_2, ... };
#define N some_number /* whatever number there are */
int i, status;
for(i=0; i<N; i++)
if((status = (*fst[i])()) == FAILURE)
break;
I checked this with trivial functions.
--
George Tomasevich, ihnp4!twitch!grt
AT&T Bell Laboratories, Holmdel, NJ
More information about the Comp.lang.c
mailing list