From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <01f601c31494$ebe8e550$644cb2cc@kds> From: "David Butler" To: <9fans@cse.psu.edu> References: <20030501160047.7231.qmail@g.bio.cse.psu.edu> <000c01c3147c$c7665ae0$7b83773e@SOMA> <3EB8E817.4090609@ameritech.net> <20030507124006.D26796@cackle.proxima.alt.za> <3EB9049D.50500@ameritech.net> Subject: Re: [9fans] same functions everywhere MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Date: Wed, 7 May 2003 07:33:05 -0500 Topicbox-Message-UUID: a16a1cb8-eacb-11e9-9e20-41e7f4b1d025 Okay, that seems *really* silly to me! Why make a subroutine call? Why re-test at the end what you know? If it can be remembered that C is really a portable assembly language, you will program in a "structured" assembly style. Use the language: int a[100]; int x, v; for (x = sizeof(a) / sizeof(a[0]); x >= 0; x--) { if (a[x] == v) { goto foundv; } } damn; foundv: cool; :) Goto is not bad, programmers that misuse goto are bad. David ----- Original Message ----- From: "northern snowfall" To: <9fans@cse.psu.edu> Sent: Wednesday, May 07, 2003 8:05 AM Subject: Re: [9fans] same functions everywhere > > > > > > int a[100]; > > int x, v; > > > > ... > > > > x = 0; > > while (x < 100 && a[x] != v) { > > ++x; > > } > > > Ok, this seems pretty silly to me, because, it just > breaks down to bad coding style. > > #include > #include > > enum { > true, > false, > }; > > // returns true if value IS found in every slot > // returns false if value is NOT found in every slot > int > gotvalue/*?*/(int * a, uint len, int val) > { > uint xa; > > for(ua = 0; ua < len; ua++) { > if(a[ua] != val) > return false; > } > return true; > } > > void > main(int argc, char * argv[]) > { > int a[100]; > > // somehow "a" gets filled with values > > if(gotvalue(&a[0], sizeof(a), 0xdeadca75) == true) > print("yay, we're true! \n"); > else > print("ick. \n"); > > exits(0); > } > > >