The FindMax() function given below is used to find the maximum value in an array of integers which has a start address in memory defined by the pointer pVals. The number of elements in the array is defined by the parameter NumEls. This function compiles and runs but the produces an incorrect result.
What is wrong with the function?
Code:int FindMax(int * pVals, int NumEls) { int i, Max = *pVals++; for (i=1; i<NumEls; ++i) { if(Max < *pVals++) Max == *pVals; } return Max; }



LinkBack URL
About LinkBacks





CornedBee
I used to be an adventurer like you... then I took an arrow to the knee.