I'm trying to make K&R 2 exercise 1-20. Everything compiles though whenever I give it a input it gives me a segmentation fault (core dumped). I don't know what this means, whats causing it and how to fix it.
#include <stdio.h>
#define MAXLINE 1000
#define TAB 4
int main()
{
  int c, i, j;  /*len is the length of the line; i & j is for for loops*/
  char line[MAXLINE];             /*Line input*/
  while ((c=getchar())!=EOF){
    if (c == '\n'){
      printf("%s", line);
      }else{
        if (c == '\t'){
          for (j=0;j<TAB+1;++j){
            line[i+j] = ' ';
          }
        }else{
      line[i] = c;
      }
    }
  }
  return 0;
}
 
     
    