Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could achieve this using <a href="http://en.cppreference.com/w/cpp/algorithm/copy" rel="nofollow noreferrer"><code>std::copy</code></a> into a <a href="http://en.cppreference.com/w/cpp/iterator/ostream_iterator" rel="nofollow noreferrer"><code>std::ostream_iterator</code></a>:</p> <pre><code>std::vector&lt;int&gt; v_Numbers; // suppose this is the type // put numbers in std::copy(v_Numbers.begin(), v_Numbers.end(), std::ostream_iterator&lt;int&gt;(cout)); </code></pre> <p>It would be even nicer if you add some suffix:</p> <pre><code>std::copy(v_Numbers.begin(), v_Numbers.end(), std::ostream_iterator&lt;int&gt;(cout, "\n")); </code></pre> <p>This assumes that your container is a <code>vector&lt;int&gt;</code>, so you will have to replace that part with the appropriate type.</p> <p><strong>Edit</strong> regarding reading input:</p> <p>Conversely, you can copy from a range of <a href="http://en.cppreference.com/w/cpp/iterator/istream_iterator" rel="nofollow noreferrer"><code>std::istream_iterator</code></a> into a <code>vector</code> using <a href="http://en.cppreference.com/w/cpp/iterator/back_inserter" rel="nofollow noreferrer"><code>std::back_inserter</code></a>:</p> <pre><code>std::vector&lt;int&gt; v_Numbers; std::copy(std::istream_iterator&lt;int&gt;(cin), std::istream_iterator&lt;int&gt;(), std::back_inserter(v_Numbers)); </code></pre> <p>If you want to read n elements only, look at <a href="https://stackoverflow.com/questions/3829885/how-to-copy-a-certain-number-of-chars-from-a-file-to-a-vector-the-stl-way">this question</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload