Hi,

I'm reading this programming book and it gives a sample code:

Code:

int get_maxpos(int x[], int eff_size)
{
int i, maxpos = 0;
for (i = 0; i < eff_size; i++)
maxpos = x[i] > x[maxpos] ? i: maxpos;
return maxpos;
}

I thought the book has made a mistake so i type the code into my compiler as:

Code:

int get_maxpos(int x[], int eff_size)
{
int i, maxpos = 0;
for (i = 0; i < eff_size; i++)
{
maxpos = x[i] > x[maxpos] ? i: maxpos;
}
return maxpos;
}

My correction turn out to be wrong since the results are different. Can you please explain to me what is the difference from having the bracket and not have a bracket?

Also, for this part: "maxpos = x[i] > x[maxpos] ? i: maxpos; " what does the "? i:" means?

Thank you