Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!ittatc!dcdwest!sdcsvax!sdcrdcf!hplabs!hpda!hpisoa2!hpitg!edison!jso@edison From: jso@edison Newsgroups: net.lang.c Subject: Re: goto jumps into loops Message-ID: <712@edison> Date: Wed, 30-Apr-86 00:54:00 EDT Article-I.D.: edison.712 Posted: Wed Apr 30 00:54:00 1986 Date-Received: Tue, 13-May-86 01:14:04 EDT References: <156@brl-smoke> Lines: 47 In respose to the program by > Dave Harmon > dmh@mit-borax.arpa > dmh@borax.lcs.mit.edu where he asks for a way to avoid a goto in his loop (translated from Pascal). How about something like..... #include #include "/usr/dmh/nastydefs" #define MAX NUM_KEYWORDS /*The highest element in use by the application*/ wrtlist (listp) set *listp; { unsigned char i; set list; list = *listp; for (i=0; i <= MAX; i++) { if (in(i,&list)) { unsigned char save_i; printf(" %d",i); save_i = i; while (++i <= MAX && in(i,&list)) ; if (i > save_i + 1) printf("-%d",i-1); /* doesn't matter that we'll i++ here, since we know !in(i,&list) */ } } printf("\n"); return(0); } [No guarantees, but you get the idea.] John Owens edison!jso%virginia@CSNet-Relay.ARPA General Electric Company Phone: (804) 978-5726 Factory Automation Products Division Compuserve: 76317,2354 houxm!burl!icase!uvacs ...!{ decvax!mcnc!ncsu!uvacs }!edison!jso gatech!allegra!uvacs