title: Ragged Arrays and For Loop errors
body: <p>I get a bad access error in the middle of the for loop, always when i=4. Does anybody know the reason for this? It works until i=4, but I don't see why I wouldn't get the bad access error in any other part of the for loop.</p>
  
  <pre><code>    #include &lt;stdio.h&gt;
      #include &lt;stdlib.h&gt;
      #include &lt;string.h&gt;
      #include &lt;ctype.h&gt;
  
      #define MAXF 51
      #define MAXFILE 200
  
  int recommend(int fid, char *funcs[]){
  int i;
  
  for(i=0; i&lt;fid; i++)
      *funcs++;
  printf("\nRecommended Function: %s\n", *funcs);
  
  return 0;
  }
  
  
  int overlap(char *list[], char name[], int n){
  int over=0, fid=202, i, j, k, m;
  
  for(i=0; i&lt;n; i++){
      m=strlen(*list);
      int lap=0;
      for(j=0; j&lt;(strlen(name)-1); j++){
          for(k=0; k&lt;m; k++)
              if(list[i][k]==name[j]){
                  lap+=1;
                  break;
              }
      }
  
      if(over&lt;lap){
          over=lap;
          fid=i;
      }
  
      *list++;
  }
  
  return fid;
  }
  
  
  int readfile(char *flist[], FILE *fptr){
  char a[MAXF];
  int size=0;
  
  while(fscanf(fptr, "%s\n", a) != EOF){
      flist[size]=malloc(sizeof(char)*(1+strlen(a)));
      strcpy(flist[size++],a);
  }
  
  return size;
  }
  
  
  int main () {
  int n, id;
  char fnname[MAXF], filename[MAXF], *flist[MAXFILE];
  FILE *fp;
  
  printf("Name of network file: ");
  gets(filename);
  printf("\nFunction Name: ");
  gets(fnname);
  
  fp=fopen(filename, "r");
  
  if(fp==NULL)
      printf("\nCould not open file.\n");
  else {
      n=readfile(flist, fp);
      id=overlap(flist, fnname, n);
      recommend(id, flist);
  }
  
  
  return 0;
  }
  </code></pre>