title: fopen Segfault error on large files
body: <p>Hello everyone I'm new to C but I've recently been getting a weird segfault error with my fopen. </p>
  
  <pre><code>   FILE* thefile = fopen(argv[1],"r");
  </code></pre>
  
  <p>The problem I've been having is that this code works on other smaller text files, but when I try with a file around 400MB it will give a sefault error. I've even tried hardcoding the filename but that doesn't work either. Could there be a problem in the rest of the code causing the segfault on this line?(doubt it but would like to know if its possible. It's just really odd that no errors come up for a small text file, but a large text file does get errors.</p>
  
  <p>Thanks! </p>
  
  <p>EDIT* didn't want to bog this down with too much but heres my code</p>
  
  <pre><code>int main(int argc, char *argv[])
  {
   if(argc != 3)
  {
  printf("[ERROR] Invalid number of arguments. Please pass 2 arguments, input_bound_file (column  1:probe, columne 2,...: samples) and desired_output_file_name");
  exit(2);
  }
  
  int i,j;
  rankAvg= g_hash_table_new(g_direct_hash, g_direct_equal);
  rankCnt= g_hash_table_new(g_direct_hash, g_direct_equal);
  table = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
  getCounts(argv[1]);
  printf("NC=: %i       nR =: %i",nC,nR);
  double srcMat[nR][nC];
  int rankMat[nR][nC];
  double normMat[nR][nC];
  int sorts[nR][nC];
  char line[100];
  
  FILE* thefile = fopen(argv[1],"r");
  printf("%s\n", strerror(errno));
  FILE* output = fopen(argv[2],"w");
  char* rownames[100];
  i=0;j = 1;
  int processedProbeNumber = 0;
  int previousStamp = 0;
  fgets(line,sizeof(line),thefile); //read file
  
  while(fgets(line,sizeof(line),thefile) != NULL)
  {
  cleanSpace(line); //creates only one space between entries
    char dest[100];
    int len = strlen(line);
    for(i = 0; i &lt; len; i++)
    {
      if(line[i] == ' ') //read in rownames
      {
      rownames[j] = strncpy(dest, line, i);
      dest[i] = '\0';
      break;
      }
    }
  
    char* token = strtok(line, " ");
    token = strtok(NULL, " ");
    i=1;
  
    while(token!=NULL) //put words into array
      {
      rankMat[j][i]= abs(atof(token));
        srcMat[j][i] = abs(atof(token));
      token = strtok(NULL, " ");
      i++;
      }
  
      // set the first column as a row id
      j++;
    processedProbeNumber++;
  
      if( (processedProbeNumber-previousStamp) &gt;= 10000)
      {
        previousStamp = processedProbeNumber;
        printf("\tnumber of loaded lines = %i",processedProbeNumber);
  
      }
  }
  printf("\ttotal number of loaded lines  = %i \n",processedProbeNumber);
  fclose(thefile);
  </code></pre>