I'm writing a program to alphabetize inputted names and ages. The ages are inputted separately, so I know I need to use an array of pointers to tie the ages to the array of names but I can't quite figure out how to go about doing it. Any ideas?
So far, my program only alphabetizes the names.
/* program to alphabetize a list of inputted names and ages */
#include <stdio.h>
#define MAXPEOPLE 50
#define STRSIZE 
int alpha_first(char *list[], int min_sub, int max_sub);
void sort_str(char *list[], int n);
int main(void)
{
    char people[MAXPEOPLE][STRSIZE];
    char *alpha[MAXPEOPLE];
    int num_people, i;
    char one_char;
    printf("Enter number of people (0...%d)\n> ", MAXPEOPLE);
    scanf("%d", &num_people);
    do
        scanf("%c", &one_char);
    while (one_char != '\n');
    printf("Enter name %d (lastname, firstname): ", );
    printf("Enter age %d: ", );
    for (i = 0; i < num_people; ++i)
        gets(people[i]);
    for (i = 0; i < num_people; ++i)
        alpha[i] = people[i];
    sort_str(alpha, num_people);
    printf("\n\n%-30s5c%-30s\n\n", "Original List", ' ', "Alphabetized List");
    for (i = 0; i < num_people; ++i)
        printf("-30s%5c%-30s\n", people[i], ' ', alpha[i]);
    return(0);
}
int alpha_first(char *list[], int min_sub, int max_sub)
{
    int first, i;
    first = min_sub;
    for (i = min_sub + 1; i <= max_sub; ++i)
        if (strcmp(list[i], list[first]) < 0)
            first = i;
    return (first);
}
void sort_str(char *list[], int n)
{
    int fill, index_of_min;
    char *temp;
    for (fill = 0; fill < n - 1; ++fill){
        index_of_min = alpha_first(list, fill, n - 1);
        if(index_of_min != fill){
            temp = list[index_of_min];
            list[index_of_min] = list[fill];
            list[fill] = temp;
        }
    }
}
 
     
     
    