title: C++ Reading a file line by line with delimiter and store data into variable
body: <p>I am quite new to C++ and I have a txt file with data which looks something like this:</p>
  
  <blockquote>
    <p>test:123:lock</p>
    
    <p>qwerty:4321:unlock</p>
    
    <p>asdf:12:lock</p>
  </blockquote>
  
  <p>Is it possible for me to read the data line by line into a variable / array using <code>":"</code> as the delimiter?</p>
  
  <p>I tried doing something like:</p>
  
  <pre><code>while(!myfile.eof()) {       
      for (int i = 0; i &lt; 3; i++) {
          getline(myfile,UserN[i],':'); 
      }
  }
  </code></pre>
  
  <p>What I want to achieve is to store the data of the first line into the <code>UserN[0]</code>, <code>UserN[1]</code>, and <code>UserN[2]</code>. And when it start reading the second line, the data on the second line will replace the value in <code>UserN[0]</code>, <code>UserN[1]</code>, and <code>UserN[2]</code>. Thanks in advance!</p>