title: Enter values in one line (STDIN)
body: <p>I have a struct called Person:</p>
  <pre class="lang-cpp prettyprint-override"><code>Person
  {
    int id;
    int age;
    int salary;
  };
  </code></pre>
  <p>So I want to enter as many Person as I want with the standard input in one line of the following form:</p>
  <p><code>[id, age, salary] [id, age, salary] ...</code></p>
  <p>So I did write this code but it doesn't give me what I'm looking for:</p>
  <pre class="lang-cpp prettyprint-override"><code>std::vector&lt;Person&gt; person;
  int y = scanf(&quot;%i&quot;, &amp;num);
  for (int i = 0; i &lt; num; i++)
  {
      Person p;
      int r = scanf(&quot;[%i,%i,%i]&quot;, &amp;p.id, &amp;p.age, &amp;p.salary);
      person.push_back(p);
  }
  </code></pre>
  <p>How can I correct my code to satisfy my need?</p>