title: change string array content with function in C
body: <p>So I am really new to C programming and trying to replace a string to a date from a file i read and then write it to an other file.
  But the problem is that when i write it into the file the string remains the same.</p>
  
  <p>What I want is to read this from a file:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;!--#include file=”date”--&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Output file</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  Sat Nov 3 14:43:53 2012
  &lt;/head&gt;
  &lt;body&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I get an error: passing argument 1 in date_change from incompatible pointer type </p>
  
  <p>Code</p>
  
  <p>//System date replacement function</p>
  
  <pre><code>void *date_change(char** s, char* str, char* date){
  
      static char buffer[4096];
      char *p;
  
      if(!(p = strstr(*s, str)))  // &lt;!--#echo var=\"date\"--&gt; find this
         return *s;
  
      strncpy(buffer, *s, p-*s); //
      buffer[p-*s] = '\0';
  
      sprintf(buffer+(p-*s), "%s%s", date, p+strlen(str));
  
      return buffer;
  }
  </code></pre>
  
  <p>//main</p>
  
  <pre><code>int main(int argc, char *argv[]){
      int f;
  
      f = open(argv[1], O_RDONLY);
  
      if(errno != 0){
          perror("Hiba");
          exit(1);
      }
  
      //read from file
      char c[1000];
      while(read(f,&amp;c, 1000)){
  
      }
  </code></pre>
  
  <p>// --------------------------------//
  Get the System date and trying to replace it with the date_change function</p>
  
  <pre><code>    time_t mytime;
      mytime = time(NULL);
      struct tm *time = localtime(&amp;mytime);
      char date[20];
      strftime(date, sizeof(date), "%c", time); //format time as string
  
      char* date_str;
  
      int g = open("data.txt", O_WRONLY | O_CREAT, 0600);
  
      //should replace all &lt;!--#echo var=\"date\" --&gt; to the system date
      while(date_str = strstr(c, "&lt;!--#echo var=\"date\"--&gt;")){
             date_change(&amp;c, date_str, date);
      }
      write(g, c, strlen(c));
  
      close(g);
  </code></pre>
  
  <p>// -------------------------------- //</p>
  
  <pre><code>    close(f);
      return 0;
  }
  </code></pre>