hi guys. i need help to make my program sort data.
in this case number that i declared as char(not string, my bada)
if i have
name1
number 2500
email
name 2
number 2400
email
i need to put that this way:
name 2
number 2400
email
name1
number 2500
email
i saw that can be done with qsort but when i try it it doesn't work.
it's really urgent
Code:
typedef struct {
char nome[MAX_GERAL], email[MAX_GERAL], morada[MAX_GERAL], postal[MAX_GERAL], numero[MAX_GERAL], geral[MAX_GERAL];
int telefone, FP, SD, AM1, ALGA, CM;
}dados;
code to add info i need to sort "numero"
Code:
void adicionar(dados* contacto){
if (i<total)
{
printf("\nIntroduza o Nome: ", i + 1);
scanf(" %[^\n]s", contacto[i].nome);
printf("Introduza o Numero de Aluno ISEL: ", i + 1);
scanf(" %s", &contacto[i].numero);
printf("Introduza a Morada: ", i + 1);
scanf(" %[^\n]s", contacto[i].morada);
printf("Introduza o Codigo Postal: ", i + 1);
scanf(" %[^\n]s", contacto[i].postal);
printf("Introduza o email: ", i + 1);
scanf(" %[^\n]s", contacto[i].email);
printf("Introduza o telefone: ", i + 1);
scanf(" %d", &contacto[i].telefone);
printf("Nota Final de FP: ", i + 1);
scanf(" %d", &contacto[i].FP);
printf("Nota Final de AM1: ", i + 1);
scanf(" %d", &contacto[i].AM1);
printf("Nota Final de SD: ", i + 1);
scanf(" %d", &contacto[i].SD);
printf("Nota Final de ALGA: ", i + 1);
scanf(" %d", &contacto[i].ALGA);
printf("Nota Final de CM: ", i + 1);
scanf(" %d\n\n\n", &contacto[i].CM);
i++;
}
else
{
printf("a lista esta cheia");
}
}