title: How to user input the array elements in c++ in one line
body: <p>I am new to c++ , Basically I belong to PHP . So I am trying to write a program just for practice, to sort an array . I have successfully created the program with static array value that is </p>
  
  <pre><code>// sort algorithm example
  #include &lt;iostream&gt;     // std::cout
  #include &lt;algorithm&gt;    // std::sort
  #include &lt;vector&gt;       // std::vector
  
  
  bool myfunction (int i,int j) { return (i&lt;j); }
  
  struct myclass { bool operator() (int i,int j) { return (i&lt;j);} } myobject;
  
  int main () {
     int myints[] = {55,82,12,450,69,80,93,33};
    std::vector&lt;int&gt; myvector (myints, myints+8);               
  
    // using default comparison (operator &lt;):
    std::sort (myvector.begin(), myvector.begin()+4);           
  
    // using function as comp
    std::sort (myvector.begin()+4, myvector.end(), myfunction); 
  
    // using object as comp
    std::sort (myvector.begin(), myvector.end(), myobject);     
  
    // print out content:
    std::cout &lt;&lt; "myvector contains:";
    for (std::vector&lt;int&gt;::iterator it=myvector.begin(); it!=myvector.end(); ++it)
      std::cout &lt;&lt; ' ' &lt;&lt; *it;
      std::cout &lt;&lt; '\n';
  
    return 0;
  }
  </code></pre>
  
  <p>its output is ok . But I want that the elements should input from user with <code>space</code> separated or <code>,</code> separated . So i have tried this </p>
  
  <pre><code>int main () {
      char values;
      std::cout &lt;&lt; "Enter , seperated values :";
      std::cin &gt;&gt; values;
    int myints[] = {values};
  
  
    /* other function same */
  }
  </code></pre>
  
  <p>it is not throwing an error while compiling. But op is not as required . It is </p>
  
  <blockquote>
    <p>Enter , seperated values :20,56,67,45</p>
    
    <p>myvector contains: 0 0 0 0 50
    3276800 4196784 4196784</p>
    
    <p>------------------ (program exited with code: 0) Press return to continue</p>
  </blockquote>