I am trying to find the minimum element of a vector in C++. I wish to return both the value of the lowest element and the position of the index within the vector. Here is what I have tried,
auto minIt = std::min_element(vec.begin(), vec.end());
auto minElement = *minIt;
std::cout << "\nMinIT " << &minIt << " while minElement is " << minElement << "\n";
This returns the following,
MinIT 8152610 while minElement is 8152610
How do I obtain the index i of vec(i) where this value is?