Originally Posted by
Heisenberg800
I solved the problem by changing the if statement to this
Code:
(strcmp(f[i].marke, f[j].marke) > 0 && f[j].marke[0] != '\0')
The empty posts seemed to create the problem. So i made sure to not if statement if the post was empty.
yeah if you're talking about the extra print outs even though it is not full, you might be able to use size of array then it will only go as far as the amount inside of it as well. that too should work. maybe not... let me try your way.
yep
you're smarter then me
but you should still take a look at its return
Code:
/* Sort after car brand*/
//int sortera(){ // does it really need a return value???
// if yes then it is missing one.
void sortera(){
// they are declared inside your for loops.
// int i,j;
fordon temp;
for (int i = 0; i < 10; i++)
{
for (int j = i+1; j < 10; j++)
{
// if (strcmp(f[i].marke, f[j].marke) > 0)
if (strcmp(f[i].marke, f[j].marke) > 0 && f[j].marke[0] != '\0')
{
temp = f[i];
f[i] = f[j];
f[j] = temp;
}
}
}
}