Code rewritten to be more clear
void indexe(char * line, unsigned ref) {
  unsigned i = 0;
  char word[128];  //(1)
  //char * word;   //(2)
  while(*line) {
    if(isalpha(*line))
      word[i++] = *line;  //(1)
      //*word++ = *line;  //(2)
    *line++;
  }
}
int main(int argc, const char * argv[]) {
  char line[128];
  FILE * f = fopen(argv[1], "r");
  unsigned x = 0;
  while (fgets(line, 128, f)){
    indexe(line, ++x);
  }
  fclose(f);
  return 0;
}
Hello, I have tried the two above combinations:
- word[] -> word[i++] 
- *word -> *word++ 
The whole thing works flawlessly, except when reaching EOF, in which case the pointers syntax fails with a segmentation fault, but not the array syntax.
I am a C total beginner, could someone explain in beginner terms what happens here, and maybe suggest a solution to fix the pointer syntax? (But mostly explain, please)
 
     
     
    