下面是关于流的问题:
请大哥们帮忙注释一下:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
double read_data (ifstream &in)
{
double highest;
double next;
if (in>>next)
highest=next;
else
return 0;
while (in>>next)
{
if (next>highest)
highest=next;
}
return highest;
}
int main()
{
string filename;
cout<<"please enter the filename:"<<endl;
cin>>filename;
ifstream infile;
infile.open(filename.c_str());
if (infile.fail())
{
cout<<"enter error!"<<filename<<endl;
return 1;
}
double max=read_data(infile);
cout<<"the maxmium value is"<<max<<endl;
infile.close();
return 0;
}