Reading lines from a text file and assigning different variables in c++
<p>I'm working on an address book application, and the portion I'm really struggling with is getting text from a .txt file and assigning the correct variable to each piece of text. each piece is delineated with a tab. </p>

<p>I'm really struggling with this one. First off, I'm not sure if my logic is 100% sound on my approach, but nevertheless, this is how it's cropped up in my head.</p>

<p>What I'd like to do is run a loop that looks at the text line by line, each line being assigned to its respective variable. </p>

<p>I know my current code isn't right, and the logic isn't fully fleshed out, but this is what I have.</p>

<p>EDIT: I forgot to mention the other variables and their respective datatypes. first name, last name, birth month/day/year, address, city, state, zip/postal code, phone number. they're virtually all strings with the exception of the birth month/day/year and zip code/postal code which are integers.</p>

<p>EDIT** 
the text file goes something like this</p>

<pre><code>Joe     Shmoe     1     1     1980     123Main     Capital     CA     90210     123-456-7890
Jane     Doe     2     5     1960     321Elm     Boise     ID     12345     987-654-3210
</code></pre>

<p>so on and so forth. What I need to do is read through the text file and fill the array elements for each attribute (first, last, month, day, year, address, city, state, zip, phone)</p>

<pre><code>void extPersonType::getInfo()
{
readFile.open("input.txt",ios::in);
if (readFile.is_open())
{
    while (readFile.good())
    {
        for (int i = 0; !readFile.eof(); i++)
        {
            getline(readFile,lines[i]);
        personInfo[i].setFirstName(lines[i]);//change this
        cout &lt;&lt; personInfo[i].getFirstName();
        }
    }
    readFile.close();
}
</code></pre>

<p>If you could help me out on this I'd appreciate it.</p>
