title: How to fix "conflicting types" for a function and its declaration?
body: <p>I want to pass a two-dimensional char array to a function but don't know how to declare the function before the main(). The function compiles and works well before I declare it. But after I declare it, I encounter compiling issues.</p>
  
  <p>I'm using EMACS on MacBook pro. The compiler is gcc.I tried to declare my function print string various ways including </p>
  
  <pre><code>void printstring(int, int,char **);
  </code></pre>
  
  <p>or </p>
  
  <pre><code>void printstring(int, int,char *); 
  </code></pre>
  
  <p>But none of them work. My Full codes are:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  #include&lt;stdlib.h&gt;
  
  void printstring(int, int,char **);
  
  int main(){
    char word[3][6]= {"hello","world","I"};
    printstring(3,6,word);
    return 0;
  }
  
  void printstring(int n, int m, char (*w)[m]){
    for (int i = 0; i &lt; n; i++){
      printf("%s\n",w[i]);
    }
    return;
  }
  </code></pre>
  
  <p>I expected that there is no compiling error but I got one error and one warning. Details can be found below:</p>
  
  <pre><code>test.c: In function 'main':
  test.c:9:19: warning: passing argument 3 of 'printstring' from incompatible pointer type [-Wincompatible-pointer-types]
     printstring(3,6,word);
                     ^~~~
  test.c:5:6: note: expected 'char **' but argument is of type 'char (*)[6]'
   void printstring(int, int,char **);
        ^~~~~~~~~~~
  test.c: At top level:
  test.c:13:6: error: conflicting types for 'printstring'
   void printstring(int n, int m, char (*w)[m]){
        ^~~~~~~~~~~
  test.c:5:6: note: previous declaration of 'printstring' was here
   void printstring(int, int,char **);
        ^~~~~~~~~~~
  </code></pre>