title: How to read in user entered comma separated integers?
body: <p>I'm writing a program that prompts the user for:</p>
  
  <ol>
  <li>Size of array</li>
  <li>Values to be put into the array</li>
  </ol>
  
  <p>First part is fine, I create a dynamically allocated array (required) and make it the size the user wants.</p>
  
  <p>I'm stuck on the next part. The user is expected to enter in a series of ints separated by commas such as: 1,2,3,4,5</p>
  
  <p>How do I take in those ints and put them into my dynamically allocated array? I read that by default cin takes in integers separated by whitespace, can I change this to commas?</p>
  
  <p>Please explain in the simplest manner possible, I am a beginner to programming (sorry!)</p>
  
  <p>EDIT: TY so much for all the answers. Problem is we haven't covered vectors...is there a method only using the dynamically allocated array I have?</p>
  
  <p>so far my function looks like this. I made a default array in main. I plan to pass it to this function, make the new array, fill it, and update the pointer to point to the new array. </p>
  
  <pre><code>int *fill (int *&amp;array, int *limit) {
  
  cout &lt;&lt; "What is the desired array size?: ";                                  
  while ( !(cin &gt;&gt; *limit) || *limit &lt; 0 ) {
      cout &lt;&lt; "  Invalid entry. Please enter a positive integer: ";
      cin.clear();
      cin.ignore (1000, 10);
  }
  
  int *newarr;                                                                            
  newarr = new int[*limit]
      //I'm stuck here
  }
  </code></pre>