This code does not give any errors but displays the array with old values without sorting by name field, it works up to reading the txt file storing data in a struct array student an instance of struct person, then when used the code to sort it and print the results of sorted array . but it does not work
#include < stdio.h > 
#include < string.h >
int main() {
    // read data from txt file and stores
    // in a struct array
    storeInarraySort();
}
int storeInarraySort() {
     // struct person with 4 fields
     struct person {
         char name[100];
         char address[100];
         char IDnumber[20];
         int age;
     };
     FILE * file = fopen("personout.txt", "r");
     // declares an struct array to store data
     struct person student[10];
     int k = 0;
     if (file != NULL)
     {
         char line[128]; /* or other suitable maximum line size */
         /* read a line */
         while (fgets(line, sizeof line, file) != NULL)
         {
             // stores values in struct array
             sscanf(line, " %99[^,], %99[^,], %19[^,], %d", student[k].name,
                 student[k].address, student[k].IDnumber, & student[k].age);
             k++;
         }
         printf("%d\n", k); // no of records in array
         fclose(file);
         // number of records k  r=k first for loop
         // inner for loop s=r+1
         //char temp;
         //struct person temp;
         for (int r = 0; r < k - 1; r++) {
             for (int s = r + 1; r < k; r++) {
                 if (strcmp(student[r].name, student[s].name) > 0) {
                     struct person temp = student[r];
                     //strcpy(temp,student[r]);
                     student[r] = student[s];
                     //strcpy(student[r],student[s]);
                     student[s] = temp;
                     //strcpy(student[s],temp);
                 }
             }
         }
         // prints struct array to check
         for (int t = 0; t < k; t++) {
             printf("%s\n %s\n %s\n %d\n ", student[t].name,
                 student[t].address, student[t].IDnumber, student[t].age);
         }
     }
}
 
     
    