well I have a template of a structure...but when I try to add something to sort the list (an attempt at a bubble sort[our instructor gave us a template about a bubble sort but I'm having troubles following it]), I'm running into some problems....any input would be appreciated, thanks
this is all inside of a struct a[...]
(program runs and user have 2 options of either entering a new item, and sorting that listed items...the entering a new item part I'm done but the sorting I'm having some trouble)
the errors that come up
"invalid operators to binary>" (line with "if statement")
"incompatib le types in assignment" (line inside of if statement : t=...)
"incompatib le types in assignment" (same line as above)
void sort(void)
{
int j, t;
for(j=1; j && n; j++)
{
if(a[j-1] > a[j]);
{
t = a[j-1]; a[j-1] = a[j]; a[j]=t;
}
}
printf("\nSorte d List:\n");
for (n=0; n < j; n++) // print sorted list
printf("Name: %s\n", j+1, a[j]);
}
this is all inside of a struct a[...]
(program runs and user have 2 options of either entering a new item, and sorting that listed items...the entering a new item part I'm done but the sorting I'm having some trouble)
the errors that come up
"invalid operators to binary>" (line with "if statement")
"incompatib le types in assignment" (line inside of if statement : t=...)
"incompatib le types in assignment" (same line as above)
void sort(void)
{
int j, t;
for(j=1; j && n; j++)
{
if(a[j-1] > a[j]);
{
t = a[j-1]; a[j-1] = a[j]; a[j]=t;
}
}
printf("\nSorte d List:\n");
for (n=0; n < j; n++) // print sorted list
printf("Name: %s\n", j+1, a[j]);
}
Comment