title: create array from a file in C
body: <p>I am trying to create a bubble sorter that takes a 2D array from a file with full names and sorts them in alphabetical order. The problem is that when the bubble sorter function is called, the program stops and stays like that indefinitely.</p>
  <p>this is the code:</p>
  <pre><code>#define _CRT_SECURE_NO_WARNINGS
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  void sortStrings(char[100][30], int);
  
  int main()
  {
      FILE* fp;
      char name[100][30];
      int list, n;
      n = 100;
      fp = fopen(&quot;List.txt&quot;, &quot;r&quot;);
      if (fp == 0)
      {
          printf(&quot;Cannot open file&quot;);
      }
      
      else
      {
          list = 0;
          while (!feof(fp)) //end of file
          {
              fgets(name[list], 30, fp);
              list++;
          }
      }
      
      sortStrings(name, n);
      
      printf(&quot;Strings in sorted order are : &quot;);
      for (int i = 0; i &lt; n; i++)
          printf(&quot;\n String %d is %s&quot;, i + 1, name[i]);
  
  
      return 0;
  }
  
  void sortStrings(char name[100][30], int n)
  {
      char temp[100];
      int i, j;
      // Sorting strings using bubble sort
      for (i = 1; i &lt;= n; i++)
          for (j = 0; j &lt;= n - i; j++)
              if (strcmp(name[j], name[j + 1]) &gt; 0)
              {
                  strcpy(temp, name[j]);
                  strcpy(name[j], name[j + 1]);
                  strcpy(name[j + 1], temp);
              }
  }
  </code></pre>
  <p>also, this error shows up in the visual studio</p>
  <p>Exception thrown at 0x6A9DF791 (ucrtbased.dll) in name organizer.exe: 0xC0000005: Access violation reading location 0xCCCCCE16.</p>