Search This Blog

Loading...

Linear search function using pointers in C

/* Linear search function using pointers in C */
long linear_search(long *pointer, long n, long find)
{
   long c;

   for (c = 0; c < n; c++) {
      if (*(pointer+c) == find)
         return c;
   }

   return -1;
}
Read More:
Simple Linear Search in C 
Linear search for multiple occurrences
Linear search using function in C

No comments:

Post a Comment