title: conflicting types error when compiling c program using gcc
body: <p>I tried to compile following program with gcc. </p>
  
  <pre><code>0 #include  &lt;stdio.h&gt;
  1 
  2 main ()
  3
  4 {    
  5  char my_string[] = "hello there";      
  6
  7  my_print (my_string);    
  8  my_print2 (my_string);    
  9}
  10   
  11 void my_print (char *string)
  12 {    
  13  printf ("The string is %s\n", string);    
  14 }
  15        
  16 void my_print2 (char *string)
  17 {
  18  char *string2;    
  19  int size, i;   
  20
  21  size = strlen (string);    
  22  string2 = (char *) malloc (size + 1);
  23
  24  for (i = 0; i &lt; size; i++)    
  25    string2[size - i] = string[i];
  26
  27   string2[size+1] = '\0';    
  28   printf ("The string printed backward is %s\n", string2);    
  29 }
  </code></pre>
  
  <p>However, it fails and the compiler produces following error log:</p>
  
  <ol>
  <li>greeting.c: 11: error:conflicting types for 'my_print'</li>
  <li>greeting.c: 7: error: previous implicit declaration of 'my_print' was here</li>
  <li>greeting.c: 16: error:conflicting types for 'my_print2'</li>
  <li>greeting.c:8: erroro:previous implicit declaration of 'my_print2' was there</li>
  </ol>
  
  <p>And if I move the my_print and my_print2 functions before the main function, everything goes well.
  So can anyone explain why the problem happens?
  Thanks!</p>