From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <3EB9049D.50500@ameritech.net> From: northern snowfall User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:0.9.4.1) Gecko/20020518 Netscape6/6.2.3 MIME-Version: 1.0 To: 9fans@cse.psu.edu Subject: Re: [9fans] same functions everywhere References: <20030501160047.7231.qmail@g.bio.cse.psu.edu> <000c01c3147c$c7665ae0$7b83773e@SOMA> <3EB8E817.4090609@ameritech.net> <20030507124006.D26796@cackle.proxima.alt.za> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 7 May 2003 08:05:33 -0500 Topicbox-Message-UUID: a15ac31c-eacb-11e9-9e20-41e7f4b1d025 > > > 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); }