Hi everyone,
Im trying to sort my array of student details by registration number. I have no idea how to go about it, but here is my code so far if anyone can help.

[CODE]
#include <string.h>
#include <stdio.h>

char seps[] = " , ";
char *token;

typedef enum Menu { FIRST = 1, NEXT, PREVIOUS, LAST, SORT, EXIT };

typedef struct
{
char fName[10];
char lName[10];
char regNo[9];
char doB[30];} PERSON;

PERSON student[10];

studenttemp[20];

EnterChoice(); // display main menu
void firstRec(); // view First record
void nextRec(); // view Next record
void previousRec(); // view Previous record
void lastRec(); // view Last record
void sortRec(); // Sort records by Registration Number

char choice;
int i;
int counter;
//-----------------------------------------------------------------------------------
int main()
{
char s[100];
FILE * f;
int len, i;
i=-1;
f = fopen("c:\\students.txt","r");

for ( ; ; ) {
fgets(s, 100, f);
if feof(f) break;
len = strlen(s);
if (len) { s[len] = 0;}
if (i>=9) break;
i++;
{
token = strtok( s, seps ); strcpy(student[i].fName, token);
token = strtok( NULL, seps ); strcpy(student[i].lName, token);
token = strtok( NULL, seps ); strcpy(student[i].regNo, token);
token = strtok( NULL, seps ); strcpy(student[i].doB, token);

}
}

fclose(f);



while ( ( choice = EnterChoice() ) != EXIT ) // menu loop
{
switch ( choice )
{
case FIRST: firstRec(); break;
case NEXT: nextRec(); break;
case PREVIOUS: previousRec(); break;
case LAST: lastRec(); break;
case SORT: sortRec(); break;
}
}
}
//------------------------------------------------------------------------------------
EnterChoice()
{
printf( "\nEnter your choice\n"
"1 - View first record\n"
"2 - View next record\n"
"3 - View previous record\n"
"4 - View last record\n"
"5 - Sort records by Registration Number\n"
"6 - End program\n? " );
scanf( "%d", &choice );
return choice;
}

void firstRec()
{
counter=0;
printf("\nFirst Name: %s\n\n", student[counter].fName);
printf("Last Name: %s\n\n", student[counter].lName);
printf("Registration Number: %s\n\n", student[counter].regNo);
printf("Date of Birth: %s\n", student[counter].doB);
}
void nextRec()
{
++counter;
if (counter >=10)
{
printf("\nThere are no more records to view!\n\n");
}
else
{
printf("\nFirst Name: %s\n\n", student[counter].fName);
printf("Last Name: %s\n\n", student[counter].lName);
printf("Registration Number: %s\n\n", student[counter].regNo);
printf("Date of Birth: %s\n", student[counter].doB);
}
}
void previousRec()
{
--counter;
if (counter <=-1)
{
printf("\nThere are no more records to view!\n\n");
}
else
{
printf("\nFirst Name: %s\n\n", student[counter].fName);
printf("Last Name: %s\n\n", student[counter].lName);
printf("Registration Number: %s\n\n", student[counter].regNo);
printf("Date of Birth: %s\n", student[counter].doB);
}
}
void lastRec()
{
counter=9;
printf("\nFirst Name: %s\n\n", student[counter].fName);
printf("Last Name: %s\n\n", student[counter].lName);
printf("Registration Number: %s\n\n", student[counter].regNo);
printf("Date of Birth: %s\n", student[counter].doB);
}

void sortRec() // Sort records by Registration Number
{

printf("\nRecords now sorted by Registration Number.\n\n");
}
[CODE]

cheers
John