title: C program - error: type mismatch with previous external decl of ‘char line []’ [-fpermissive]\
body: <p>I am new to c language.  So, I copied code out of Brian Kernighan and Dennis Ritchie 's book(The C programming language).  I was copying pg32 example.  When I got this error:</p>
  
  <pre><code>pg32.c: In function ‘int main()’:
  pg32.c:16:23: error: type mismatch with previous external decl of ‘char longest []’ [-fpermissive]
  pg32.c:7:6: error: previous external decl of ‘char longest [1000]’ [-fpermissive]
  pg32.c: In function ‘int getl()’:
  pg32.c:33:20: error: type mismatch with previous external decl of ‘char line []’ [-fpermissive]
  pg32.c:6:6: error: previous external decl of ‘char line [1000]’ [-fpermissive]
  pg32.c: In function ‘void copy()’:
  pg32.c:50:20: error: type mismatch with previous external decl of ‘char line []’ [-fpermissive]
  pg32.c:6:6: error: previous external decl of ‘char line [1000]’ [-fpermissive]
  pg32.c:50:31: error: type mismatch with previous external decl of ‘char longest []’ [-fpermissive]
  pg32.c:7:6: error: previous external decl of ‘char longest [1000]’ [-fpermissive]
  </code></pre>
  
  <p>I retype the code 4 time, same error.  I am not sure, but I think it is is a legacy problem.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  #define MAXLINE 1000
  
  int max;
  char line[MAXLINE];
  char longest[MAXLINE];
  
  int getl(void);
  void copy(void);
  
  int main()
  {
    int len;
    extern  int max;
    extern char longest[];
  
    max =0;
    while((len =getl()) &gt; 0)
      if(len &gt; max){
        max = len;
      copy();
      }
  
    if(max &gt; 0)
      printf("%s", longest);
    return 0;
  }
  
  int getl(void)
  {
    int c, i;
    extern char line[];
  
    for(i =0; i &lt; MAXLINE-1 &amp;&amp;
      (c=getchar()) != EOF &amp;&amp; c != '\n'; ++i)
      line[i] =c;
  
    if(c=='\n'){
      line[i] = c;
      ++i;
    }
    line[i] ='\0';
    return i;
  }
  
  void copy(void)
  {
    int i;
    extern char line[], longest[];
  
    i=0;
    while((longest[i] = line[i]) != '\0')
      ++i;
  }
  </code></pre>
  
  <p>I appreciate any help.</p>