I have a vector of doubles and I need to get the maximum value within it and then store the value inside an integer variable so that I can compare the value. I have this so far:
vector<double>::iterator result;
result = max_element(zerocrossdata.begin(), zerocrossdata.end());
How can I place the value inside a variable?
You need to deference the iterator using the * operator, as has already been stated by others:
However, be aware that the result of this operation will be a double, not an int. On almost all platforms, double will be an 8 byte floating point value. Your result could be outside the range of values an int (typically a signed 4-byte integer) can support. This could result in unexpected behaviour, and you may (or may not) get a compiler warning about it, depending on your compiler and settings.