how is this done not really sure .
Code:
//prototype
void improvedbubblesort (struct team Table[]);
//this is defined out side of main
struct team
{
char name[20] ;
int points ;
int goalsscored ;
int goalsconceeded ;
};
int main(void)
{
//how array is defined and initilize in main
struct team Table[20]={{{{0}}}} ;
//how function is called
improvedbubblesort(Table) ;
return 0 ;
}
//implementation of function
void improvedbubblesort(struct team Table[])
{
int i ;
int No_Els = 10 ;
int pointsTemp ;
int goalsScoredtemp ;
int goalsConcTemp ;
char name[25];
bool No_swaps ;
for( i = 0 ; i < No_Els - 1 ; i ++ )
{
//set bool to true assume No swaps to be made
for( int j = 0 ; j < No_Els - i - 1 ; j ++ )
{
No_swaps = true ;
if(Table[j].points > Table[j+1].points )
{
//swap name
strcpy(name,Table[j].name) ;
strcpy(Table[j].name,Table[j+1].name) ;
strcpy(Table[j+1].name,name) ;
//swap points
pointsTemp = Table[j].points ;
Table[j].points = Table[j+1].points ;
Table[j+1].points = pointsTemp ;
//swap goalsscored
goalsScoredtemp = Table[j].goalsscored ;
Table[j].goalsscored= Table[j+1].goalsscored ;
Table[j+1].goalsscored = goalsScoredtemp ;
//swap goalssconceeded
goalsConcTemp = Table[j].goalsconceeded ;
Table[j].goalsconceeded = Table[j+1].goalsconceeded ;
Table[j+1].goalsconceeded = goalsConcTemp ;
//****swaps made change bool****//
No_swaps = false ;
}//****end if****//
}//end for
if(No_swaps == true )
{
printf("noswaps made \n " ) ;
getchar() ;
break ;
}
}//end for
}
the whole code is very long but can post if necessary .
Basically i get no errors in this but its not sorting them .
Think its in the way i pass the array of struct .
any help would be good.