title: C++ - How to input space separated numbers into array?
body: <p>I have this file:</p>
  
  <pre><code>4
  10 3 4 6
  </code></pre>
  
  <p>The first line declares how many numbers the second line has.I want to put the numbers of the second line in an array.So far i have been using this loop to automatically declare how many numbers the second line has and how many times to do the loop:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  
  using namespace std;
  
  int main(){
      ifstream infile;
      infile.open("input.in");
      string kids;
      int x;
      int i;
      getline(infile,kids);
      cout &lt;&lt; "The Number Of Kids Is " &lt;&lt; kids &lt;&lt; endl;
      istringstream buffer(kids);
      int kidss;
      buffer &gt;&gt; kidss;
      for(i=0;i&lt;kidss;i++){
          infile &gt;&gt; x;
          cout &lt;&lt; x &lt;&lt; " ";
      }
      infile.close();
      return 0;
  }
  </code></pre>
  
  <p>Now i want to do the same thing but instead of inputing the numbers in x i want to put them in an array and then display them as above.Thanks In Advance!</p>