C programming sort of student records
So I have to read a file that contains student records in the form:
lastname, firstname:studentid:score1:score2:score3:score4:sc ore5:grade
and store them in an array of structures. I then have to print a menu for the user to chose what they want to do with the list of records (i.e. sort or print). Anyways, I am having trouble with my sort algorithm. It only swaps the first letter of each name and I need it to swap the whole record. I do not have to sort by last name and first name, only by the first letter of each name field in the list. Can anyone help?
insert
Code:
void sortListName(STUDENT records[], int count)
{
int smallest;
int tempData;
int current;
int walk;
for (current = 0; current < count; current++)
{
smallest = current;
for (walk = current + 1; walk <= count; walk++)
{
if ((strcmp(records[walk].name, records[smallest].name)) < 0)
smallest = walk;
}
tempData = *records[current].name;
*records[current].name = *records[smallest].name;
*records[smallest].name = tempData;
}
return;
}