初学C++,在用VS2017编译书上例子时,报错,请指点!
#include "stdafx.h"
#include "std_lib_facilities.h"
struct Reading {
int hour;
double temperature;
};
int main() {
cout << "Please input a name" << endl;
string iname;
ifstream ist{ iname };
if (!ist) error("can't open input file name", iname);
string oname;
cout << "please input name of output file: ";
cin >> oname;
ofstream ost{ oname };
if (!ost) error("can't open output file", oname);
vector<Reading>temps;
int hour;
double temperature;
while (ist >> hour >> temperature){
if (hour < 0 || 23 < hour) error("hour out of range");
temps.push_back(Reading{ hour,temperature });
}
for ( int i = 0; i< temps.size(); ++i)
ost << '(' << temps[i].hour << ','
<< temps[i].temperature << ")";
}