This tutorial shows how to print the address of an iterator in C++.
Example: C++ Print Iterator Address
#include <iostream> #include <vector> std::ostream &operator<<(std::ostream &os, const std::vector::iterator &i) { os << &i; return os; } int main(int argc, const char *argv[]) { std::vector inputs = {15, 20, 10, 5, 19}; std::vector::iterator i; i = inputs.begin(); std::cout << i << "\n"; std::cout << &i; }
Output:
0x7ffe1ebffa20 0x7ffe1ebffa20