Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!mcnc!ncsu!uvacs!edison!jso From: jso@edison.UUCP (John Owens) Newsgroups: net.lang.c Subject: Re: goto jumps into loops Message-ID: <712@edison.UUCP> Date: Tue, 29-Apr-86 15:54:02 EDT Article-I.D.: edison.712 Posted: Tue Apr 29 15:54:02 1986 Date-Received: Sat, 3-May-86 02:03:00 EDT References: <69@brl-smoke.ARPA> Organization: General Electric Company, Charlottesville, VA 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