在读文件输入到vector容器时发生错误
类文件:
class Map
{
public:
Map();
const int maxmax = 260101;
int maxOfcolumns = 900;
int numOfRows = 289; //txt文件的大小就是900*289
vector<char>map;
};
具体实现:
map.resize(260101);
map.reserve(260101);
ifstream file;
file.open("001.txt", ios::in);
if (!file)
{
cerr << "File could not be opened" << endl;
exit(EXIT_FAILURE);
}
int i = 0;
file >> noskipws;
while (!file.eof() && i < maxmax)
{
file >> map[i]; //这里报错
i++;
} //这里场景被存进一维容器
不知道是哪里出了问题,但是之前写过一模一样的这里也没报错
谢谢,问题已经解决了,是源文件里有个函数的问题,并不是此处的问题
int i = 0;
file >> noskipws;
while (!file.eof() && i < maxmax)
{
char c1 = file.get();
map[i]=c1;
i++;
} //这里场