title: How to convert vector iterator to int in C++
body: <p>I am looking for an element in a C++ vector, and when I find it, I want to get found element's index in a numerical form(integer, float).</p>
  
  <p>My naive attempt is this : </p>
  
  <pre><code>int x;
  int index;
  vector&lt;int&gt; myvector;
  vector&lt;int&gt;::iterator it;
  it = find(myvector.begin(), myvector.end(), x);  
  index = (int) * it;
  </code></pre>
  
  <p>This code is giving error. Can you tell me how I can convert iterator to int(if possible), or can you tell me how I can get found element's index in other way? Thanks.</p>