title: strstr char array inside struct array
body: <p>I have a struct defined as;</p>
  
  <pre><code>struct player {
  
      int no, age;
  
      char name[20];  
  
  } players[10];
  </code></pre>
  
  <p>Array is filled from file. What I try to do is, take input from user, add input to char array, send it to search(char lookup[]) function and <code>strstr</code> name field in a loop.</p>
  
  <p>EDİT: Sorry I corrected the order. I'm trying to strstr in a loop.</p>
  
  <pre><code>char *p = strstr(players[x].name, inputFromUser);
  </code></pre>
  
  <p>but <code>p</code> is always null. How can I do this?</p>
  
  <p>Thanks in advance. </p>
  
  <p>EDIT - Code Added... </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;string.h&gt;
  
  struct player {
  
      int no, age;
  
      char name[20];  
  
  } players[20];
  
  void fillstruct(char *);
  void search(char []);
  
  int main(int argc, char *argv[])
  {
      int arg;
      int c;        
      int d;           
      int i=0;        
  
      char a[100];
      char *filename = NULL;
  
      while((arg=getopt(argc, argv, "f:"))!=-1)
      {
          switch(arg)
          {
              case 'f':
                  filename = optarg;
                  fillstruct(filename);
                  break;
              default:
                  break;
          }
      }   
      while((c=fgetc(stdin))!=EOF)
      {
          if(c!=10)
          {
              a[i]=c;
              i++;
          }       
          else
          {
              a[i]='\0';
              search(a);      
              i=0;            
          }       
      }
      return 0;
  }
  
  void search(char a[])
  {
      int i=0;
      int col;
      int found=0;
      char *p =NULL;
      while((i&lt;20)&amp;&amp;(found==0))
      {
          p = strstr(a, players[i].name);
          if(p)
          {
              col = p-a;
              printf("\nPlayer '%s' found in '%s'.. Found index: %d", a, players[i].name, col);
              found=1;
          }   
          else
          {
              printf("\np=%s a=%s player[%d].name=%s", p, a, i, players[i].name);
          }
          i++;
      }   
  }
  
  void fillstruct(char *name)
  {
      FILE *fp;
      char line[100];
      int i=0;
  
      fp = fopen(name, "r");
      if(fp==NULL)
      {   
          exit(1);
      }
  
      while(fgets(line, 100, fp)!=NULL)
      {
          players[i].no=i;
          strcpy(players[i].name, line);
  fprintf(stdout, "\nplayer=%s", players[i].name);
          players[i].age=20;
          i++;
      }   
      fclose(fp); 
  }
  </code></pre>