Oh, also in the sort, you don't need to move the strings around, just the pointers. That removes the need to malloc more memory:
Code:
for (i = 0; i < count; i++) {
for (k = i + 1; k < count; k++) {
if(bk[i].LastName == NULL ||bk[k].LastName == NULL) // Avoid segfaults with deleted items
continue;
//My if statement to manually sort user data in alphabetical order by last name
if (strcmp(bk[i].LastName,bk[k].LastName) > 0) {
char *temp;
temp = bk[k].FirstName;
bk[k].FirstName = bk[i].FirstName;
bk[i].FirstName = temp;
temp = bk[k].LastName;
bk[k].LastName = bk[i].LastName;
bk[i].LastName = temp;
temp = bk[k].number;
bk[k].number = bk[i].number;
bk[i].number = temp;
}
}
}
Also, you are only sorting by LastName, your comment indicates you know that