Reading Min and Max From Text File I am trying to write a program that will read the highest and lowest voltage along with its associated amp and time. I am able to find the max, but I am getting all zeros for the minimum value. I need help. Please and thank you.

Sample of txt file:

Time    Volt    Ampere
0.0001  9.77667 0.147408
0.00015 9.76583 0.147525
0.0002  9.76833 0.147692
0.00025 9.75833 0.147442
0.0003  9.76833 0.147192
0.00035 9.78167 0.1473
0.0004  9.76667 0.147317
0.00045 9.765   0.14715
0.0005  9.75667 0.147
0.00055 9.765   0.14695
0.0006  9.77    0.1471
0.00065 9.7675  0.147417
0.0007  9.7725  0.147417
0.00075 9.755   0.14735
0.0008  9.765   0.147725
0.00085 9.76583 0.147783


Expected Min Output:

Time = 0.00075  Volt = 9.755 Ampere = 0.14735


Expected Max Output:

Time= 0.00035 Volt = 9.78167 Ampere = 0.1473




int main(void)
{
//Declare Variables
string a, b, c;

double time, volt, ampere;
double maxVolt = 0, maxTime, maxAmpere;
double minVolt = 10, minTime, minAmpere;

//Read from the Volts.txt file
ifstream myFile("D:\\tabit\\Documents\\Volts.txt");

//Check if the file can be opened
if (myFile.is_open())
{
    while (myFile &gt;&gt; a &gt;&gt; b &gt;&gt; c)
    {
        time = atof(a.c_str());
        volt = atof(b.c_str());
        ampere = atof(c.c_str());

        if (volt &gt;= maxVolt)
        {
            maxTime = time;
            maxVolt = volt;
            maxAmpere = ampere;
        }
        if (volt &lt; minVolt)
        {
            minTime = time;
            minVolt = volt;
            minAmpere = ampere;
        }
    }
    //Close the file
    myFile.close();
}
//Give error message if the file cannot be opened
else return(1);

//Display the Maximum results
cout &lt;&lt; "Max Volt: " &lt;&lt; maxVolt &lt;&lt; endl;
cout &lt;&lt; "Max Time: " &lt;&lt; maxTime &lt;&lt; endl;
cout &lt;&lt; "Max Ampere: " &lt;&lt; maxAmpere &lt;&lt; endl;

//Display the Minimum results
cout &lt;&lt; "Min Volt: " &lt;&lt; minVolt &lt;&lt; endl;
cout &lt;&lt; "Min Time: " &lt;&lt; minTime &lt;&lt; endl;
cout &lt;&lt; "Min Ampere: " &lt;&lt; minAmpere &lt;&lt; endl;

return 0;
}
The value of atof("Volt") is zero.  The corresponding values of atof("Time") and atof("Ampere") are also zero, which gives you the minimum values of zero you observed.  

You need to skip the first line of the file.  Adding this before the while loop would work:

myFile.ignore(80, '\n');


Use std::numeric_limits&lt;std::streamsize&gt;::max() instead of 80 for a more correct (but verbose) limit of characters to skip before the new line character. 



After you add the skipping of the first line, you no longer need the a, b &amp; c variables and atof() calls;  you can read the values directly:

while (myFile &gt;&gt; time &gt;&gt; volt &gt;&gt; ampere)