title: Is there an indexOf equivalent for arrays in C?
body: <p>I'm brand new to C and hope there's something built in that I can use.  Say I have a list and I want to find the location of a list(all items in the lists are unique). Like so:
  <code>char *name[] =  {"monkey", "pig", "goat", "dog", "cat"};</code> I tried:</p>
  
  <pre><code>   char *name[] =  {"monkey", "pig", "goat", "dog", "cat"};
     int *found = strstr (*name,"dog");
     printf("Found at %i \n", found); //expect 3(or 4, if it doesn't use 0s) result
  </code></pre>
  
  <p>but it keeps giving me the result of 2(even if I put names that don't exist). I swapped <code>strstr</code> with <code>strcspn</code> with no luck either.</p>
  
  <p>I am asking because I wasn't sure and I created my own function to do this but its pretty crappy and not very flexible(I hardcode the list name in it), I figured if there's something within C then it'll be better for me. Here's the function I made(cover your eyes if you don't want to lose brain cells reading it, joking :-):</p>
  
  <pre><code>int indexOf(char nameToFind) {
      //returns the location of an item in a list
      int pos = -1;
      int i;
      for (i = 0; i &lt; sizeof(name) / sizeof(name[0]) &amp;&amp; pos == -1; i++)
      {
          // Assuming there is a char[] field called name in Stdinfo
          if (*name[i] == nameToFind) {
              pos = i;
          }
      }
      return pos;
  }
  </code></pre>
  
  <p>Does something like this exist in C that would be faster &amp; more flexible than my version?</p>