file reading in C++
<p>Could someone help me figure out what this C++ code does I got it somewhere but want to understand it. I have figured out some of it but some things I cannot get my head around. Here it is:</p>

<pre><code>vector&lt;double&gt; prices;            // vector of option prices
vector&lt;int&gt; strikes;                // vector of strikes
char buffer[100];                   // buffer for line read
char dataBuffer[100];         // stores current data string read
char *str = NULL;                   // pointer to data string
const char *file = "optionData.txt"; // file with option chain info
ifstream fin;                        // input file stream

fin.clear();
fin.open(file);
if (fin.good())
{
    while (!fin.eof()){
        // read in one line at a time
        fin.getline(buffer,sizeof(buffer)/sizeof(buffer[0]));
        ifstream str1(buffer);

        // Get data
        str1 &gt;&gt; dataBuffer; // read data from file
        while (!str1.eof()){
            // read in contract maturity, strike, and price
            str1 &gt;&gt; dataBuffer;       // read option maturity month
            str1 &gt;&gt; dataBuffer;       // read option maturity year

            str1 &gt;&gt; dataBuffer;       / read option maturity strike
            // convert strike char* data to integers
            // and add to strike vector
            strikes.push_back(atoi(dataBuffer));

            str1 &gt;&gt; dataBuffer;       // read option market price
            // convert option price char* data to floats
            // and add to strike vector
            prices.push_back(atof(dataBuffer));
        }

        buffer[strlen(buffer) + 1] = '\0';
    }
}
else
{
    cout &lt;&lt; "File not good!" &lt;&lt; "\n";
}
// close file
fin.close();
</code></pre>

<p>What i dont get is the following  </p>

<ol>
<li><code>ifstream str1(buffer);</code>  </li>
<li><code>fin.getline(buffer,sizeof(buffer)/sizeof(buffer[0]));</code><br>
particularly <code>sizeof(buffer)/sizeof(buffer[0])</code>  </li>
<li><code>buffer[strlen(buffer) + 1] = '\0';</code>  </li>
<li><code>str1 &gt;&gt; dataBuffer;</code>  </li>
</ol>

<p>The file being read is "optionData.txt" and a sample of it is:</p>

<pre><code>Jan 03 35.00 40.50 Jan 03 95.00 0.30 
Jan 03 40.00 25.30 Jan 03 100.00 0.20 
Jan 03 45.00 29.50 Jan 03 105.00 0.05 
Jan 03 50.00 16.80 Jan 03 110.00 0.10 
Jan 03 55.00 12.60 Jan 03 115.00 0.15 
Jan 03 60.00 9.30 Jan 03 120.00 0.15 
Jan 03 65.00 6.40 Jan 03 125.00 0.10 
Jan 03 70.00 4.10 Jan 03 130.00 0.10 
Jan 03 75.00 2.60 Jan 03 140.00 0.10 
Jan 03 80.00 1.50 Jan 03 150.00 0.05 
Jan 03 85.00 0.90 Jan 03 155.00 0.00 
Jan 03 90.00 0.50 Jan 03 160.00 0.05
</code></pre>

<p>Please be patient with me I am teaching myself c++. I ran it but it freezes my machine.</p>
