c++ - How should I correct this code that causes "value computed not used" warning? -


I have an array of doubles and need to make a calculation on that array and then get the minimum and maximum value That's what I originally got here:

  double * array; Double results; Double Mimin; Double myMax; // array is properly initialized ... for (int i = 0; i & lt; sizeOfArray; ++ i) {result = transmographie (array [i]); If (i == 0) {myMin = results; MyMax = Results; } And if (result & lt; myMin) {myMin = result; } And if (result> myMax) {myMax = results; }}  

I'm getting a warning that the value to be calculated for results is never, and since we have all the warnings in the form of errors , It does not compile. How can I fix this code to avoid warning? I am using G ++ for my compiler.

Here is the warning text:

  cc1plus: Warning to be treated as errors foo.cc:< Transmogrify call linen; Error: The calculated value is not used  

Edit: I do not get the vote below, but I have some things to do now. Thanks for everyone for taking the time.

Assume that you the result outside the loop, Can declare inside results :

 for  (int i = 0; i & lt; sizeOfArray; ++ I) {double result = transmaggerate (Array [ I]); ...}  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -