title: Sorting an Array of Strings in C using functions
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  void bubble_sort_grades(char [], int); 
  int main(void)
  {
      int menuswitch=1;
      int amountofstudents;
      int i;
      int z;
      char studentinfo[100];
      char fname[50][100];
      char lname[50][100];
      char grade[50][100];
      printf("Enter Amount of Students: ");
      scanf("%d ", &amp;amountofstudents);
      for (i=0;i&lt;amountofstudents;i++)
      {
          fgets(studentinfo, sizeof(studentinfo), stdin);
          strcpy(fname[i], strtok(studentinfo, " "));
          strcpy(lname[i], strtok(NULL, " "));
          strcpy(grade[i], strtok(NULL, " "));
      }
          while (menuswitch==1)
          {
              int answer;
              printf("Enter 1 for Alphabetical Sort (First Name) \n");
              printf("Enter 2 for Alphabetical Sort (Last Name) \n");
              printf("Enter 3 for Score Sort \n");
              printf("Enter 0 to exit \n");
              printf("Enter choice now: ");
              scanf("%d", &amp;answer);
              if (answer==1)
              {
                  bubble_sort_grades(grade,amountofstudents);
                  printf("%s\n", grade[0]);
                  printf("%s\n", grade[1]);
              }
              if (answer==2)
              {
                  printf("In 2 \n");
              }
              if (answer==3)
              {
                  printf("In 3 \n");
              }
              if (answer==0)
              {
                  printf("Ending Program \n");
                  menuswitch=0;
              }
          }
  }
  void bubble_sort_grades(char grades2[], int amount)
  {
      int c, d , t;
      for (c=0; c&lt;(amount); c++)
      {
          for (d=0; d&lt;amount-1; d++)
          {
              if (grades2[c]&gt;grades2[d+1])
              {
                  t=grades2[d+1];
                  grades2[d+1]=grades2[d];
                  grades2[d]=t;
              }
          }
      }
  }
  </code></pre>
  
  <p>Sorry for asking another questions but I need help on bubble sorting. I created a function to bubble sort the grades of students from the input. Yet, when I do this I get only the first grade sorted instead of the array. </p>
  
  <pre><code>   Input:
      John Smith 86
      Victor Jones 76
  </code></pre>
  
  <p>Output:
  68
  76</p>