title: How to iterate first ten items from the container
body: <p>I want to print only first 10 inserted items while leaving the rest behind. What code do i have to use (instead of using <code>myset.end()</code> ) to print only first 10 integers instead of printing every single integer.</p>
  
  <pre><code>int main ()
  {
  std::set&lt;int&gt; myset;
  std::set&lt;int&gt;::iterator it;
  
  // set some initial values:
  for (int i=1; i&lt;=20; ++i) 
      myset.insert(i*10);    
  
  std::cout &lt;&lt; "myset contains:";
  for (it=myset.begin(); it!=myset.end(); ++it)
  std::cout &lt;&lt; *it &lt;&lt; ' ';
  std::cout &lt;&lt; "\n\n";
  
  return 0;
  }
  </code></pre>