M
Maria Mela
Hello everybody...
What´s wrong in may sort function??
I call this function, and after i list all stuct... but "sortbyname"
function doesn´t do nothing... why??
can you help me??
Thks
Kisses
void sortbyname (void)
{
int sort_Counter = 0, i = 0;
if(firsta==NULL)
{
puts("Nao existem Registos!");
return;
}
currenta = temp;
while(currenta != NULL)
{
sort_Counter++;
currenta = currenta->next;
}
currenta = temp;
for(;i < sort_Counter;i++)
{
while(currenta != NULL)
{
if(currenta->next != NULL)
{
if( strcmp(currenta->nome, currenta->next->nome) > 0 )
{
temp = (struct aluno *) malloc( sizeof(struct aluno ) );
if( temp != NULL )
{
strcpy( temp->nome,currenta->nome );
strcpy( temp->curso, currenta->curso );
strcpy( currenta->nome, currenta->next->nome );
strcpy( currenta->curso, currenta->next->curso );
}
}
}
currenta = currenta->next;
}
currenta = temp;
}
}
What´s wrong in may sort function??
I call this function, and after i list all stuct... but "sortbyname"
function doesn´t do nothing... why??
can you help me??
Thks
Kisses
void sortbyname (void)
{
int sort_Counter = 0, i = 0;
if(firsta==NULL)
{
puts("Nao existem Registos!");
return;
}
currenta = temp;
while(currenta != NULL)
{
sort_Counter++;
currenta = currenta->next;
}
currenta = temp;
for(;i < sort_Counter;i++)
{
while(currenta != NULL)
{
if(currenta->next != NULL)
{
if( strcmp(currenta->nome, currenta->next->nome) > 0 )
{
temp = (struct aluno *) malloc( sizeof(struct aluno ) );
if( temp != NULL )
{
strcpy( temp->nome,currenta->nome );
strcpy( temp->curso, currenta->curso );
strcpy( currenta->nome, currenta->next->nome );
strcpy( currenta->curso, currenta->next->curso );
}
}
}
currenta = currenta->next;
}
currenta = temp;
}
}