title: Search string in file (C)
body: <p>So my code isn't working...</p>
  
  <pre><code>test.c:27: warning: passing argument 1 of ‘search’ from incompatible pointer type
  </code></pre>
  
  <p>which is the fgets line.</p>
  
  <p>My code opens a file, reads the file line by line, and I'm trying to create a "search" function that will return a value that indicates whether that string is found on that line of the file.</p>
  
  <p>My ultimate goal is to achieve a search and replace program. But one step at a time eh?
  this is what I have so far:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int search(const char *content[], const char *search_term)
  {
      int t;
  
      for(t=0; content[t]; ++t){
          if(!strcmp(content[t], search_term)){
              return t; // found
          }
      }
      return 0; // not found
  }
  
  
  int main(int argc, char *argv[])
  {
      FILE *file;
      char line[BUFSIZ];
      int linenumber=0;
      char term[20] = "hello world";
  
      file = fopen(argv[1], "r");
      if(file != NULL){
          while(fgets(line, sizeof(line), file)){
              if(search(line, term) != -1){
                  printf("Search Term Found!!\n");
              }
              ++linenumber;
          }
      }       
      else{
          perror(argv[1]); 
      }
  
      fclose(file);
      return 0;
  }
  </code></pre>