我对下面的代码有疑问。在这里,我想编写一个程序,该程序将从文件中获取输入并将其存储在结构向量中,但是当我声明结构类型向量时,它会显示错误。
#include<iostream>
#include<fstream>
#include<vector>
using namespace std;
struct input
{
char process[10];
int burst_time;
int arrival_time;
}input;
int main()
{
ifstream myfile;
vector<input> store;// problem with initializing vector
myfile.open("input.txt",ios::in);
if(myfile.is_open())
{
while(!myfile.eof())
{
myfile>>input.process;
myfile>>input.burst_time;
myfile>>input.arrival_time;
store.push_back(input);//showing problem in this line also
}
}
myfile.close();
return 0;
}