I'm trying to sort 6 numbers input by the user using a bubble sort algorithm. My program has to be modular so I've written the program as a separate function but I keep getting two errors and I have no idea how to correct them.
Error 1. Lvalue required in function sort_Nums(int *)
Error 2. Expression syntax in function sort_Nums(int *)
Here's my code:
void sort_Nums(int*picked_nums)
{
int i,step,temp;
for(step=0; step<SIZE-1; ++step)
for(i=0; i<SIZE-step-1; ++i)
{
if(*(picked_nums+i) > *(picked_nums+i)+1)
{
temp=*(picked_nums+i);
*(picked_nums+i) = *(picked_nums+i)+1;
*(picked_nums+i)+1 = temp;
}
}
printf("The numbers you chose in order are:\n");
for(i=0; i=<SIZE; ++i)
{
printf("%d\n", *(picked_nums+i));
}
printf("Press any key to return to main menu");
getchar();
}
Thanks in advance and I am sorry if this is a stupid question and its just a syntax error or something but I've been coding for 9 hours almost now and this assignment is due tomorrow so this is a kind of last resort thing.
for(i=0;i=<10;++i)really?=<*(picked_nums + (i + 1 )is what you need, I think.