title: C: how would I write a search function to look for a match in a struct array, and return (print) the entire struct it matched?
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #define RECORDS 10  
  </code></pre>
  
  <p>The function below is what I am asking for help with. </p>
  
  <pre><code>static char searchforRecordbystate(char input[3])
  {   
  </code></pre>
  
  <p>for / while /if loop</p>
  
  <p>search struct array members </p>
  
  <p>if a match is found</p>
  
  <p>return (print) the entire struct where a match was found</p>
  
  <pre><code>    return 0;
  }   
  </code></pre>
  
  <p>Main function - first time ever using pointers, (xcode is not complaining with it set to be as strict as possible) but all of you are welcome to complain, especially if I am making a huge oversight. </p>
  
  <pre><code>int main() {
      typedef struct {
          char *firstName[RECORDS];
          char *lastName[RECORDS];
          char *street[RECORDS];
          char *city[RECORDS];
          char *state[RECORDS];
          int *zip[RECORDS];
          char *phone[RECORDS];
          int *accountId[RECORDS];
      } Customer ;    
  
      typedef int records;
      records i = 0;  
  </code></pre>
  
  <p>array loop for data entry </p>
  
  <pre><code>    Customer custArray[RECORDS];
      printf("================================================================\n");
      for(i = 0; i &lt; RECORDS; ++i)
      {
          printf("Enter data for customer %d\n", i + 1);
          printf("Enter firstname, last name, phone\n");
          scanf("%s %s %s", *custArray[i].firstName, *custArray[i].lastName, *custArray[i].phone);
          printf("Enter Address (Street City State ZIP)");
          scanf("%s %s %s*c %d", *custArray[i].street, *custArray[i].city, *custArray[i].state, *custArray[i].zip);
          break;
      }
      char input[3];
      printf("Enter in state to search for customer a customer record:\n");
      scanf("%s", input); 
  
  
      searchforRecordbystate(input);  
  
  }   
  </code></pre>
  
  <p>No error checking necessary, just trying to crawl into learning c at the moment. And there will not be duplicate data in the state member. Hope that makes this easier. </p>