View Single Post
  #8  
Old 09-15-2007, 06:22 PM
IRuleYouHard IRuleYouHard is offline
Senior Member
 
Join Date: Nov 2006
Location: MS Paint Forum.
Posts: 1,050
Default Re: C Programming Halp! :)

<font class="small">Code:</font><hr /><pre>
BOOLEAN SequentialSearch(ARRAY_LIST *plist, YEAR targetYear, int *loc)
{
int i; /* loop control variable */
int numFound; /* counts how many found */
BOOLEAN found; /* return value TRUE if success FALSE if not */

numFound = 0; /* set to none in the beginning */
found = FALSE; /* initial setting until a record is found */

/* search through the array list for targets */
for(i = 0; i &lt; plist-&gt;count; i++)
{
if (EQ(targetYear, plist-&gt;car[i].year)) /* target year is found */
{
loc = loc;
numFound++; /* add one to the count */

/* ********
HERE IS WHERE YOU WILL WANT TO HANDLE DISPLAYING THE CAR RECORD.
EITHER DIRECTLY, OR BY CALLING A FUNCTION TO DO IT
********* */

found = TRUE; /* successfully found at least one record */

}
}
printf("\n\n %d record(s) found that match\n", numFound);
i = 0; /* reset value of i */
return found;
}
</pre><hr />
Reply With Quote