到目前为止,我有一个仅包含句点(“。”)的向量,我想用从输入文件中获取的符号替换网格上的某些坐标。我正在使用替换方法,但不断收到此错误
“错误:没有用于调用替换的匹配函数(std::basic_string、std::allocator >&、std::basic_string、std::allocator >&、const char [2]、const char*)”
我不确定那个错误是什么意思。我感谢任何和所有的帮助。提前致谢
这是我的代码
#include <vector>
#include <string>
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
string locationfilename, filenames,symbol;
int numRows, numCols, startRow, startCol, endRow, endCol, possRow, possCol, id;
cout<< "Enter Locations Filename"<<endl;
cin>>locationfilename;
cout<< "Enter Names Filename"<<endl;
cin>>filenames;
ifstream locations(locationfilename.c_str());
ifstream names(filenames.c_str());
locations>>numRows>>numCols>>startRow>>startCol>>endRow>>endCol;
vector <string> rows(numCols,".");
vector< vector<string> > grid(numRows,rows);
locations>>possRow>>possCol>>symbol>>id;
while(!locations.fail())
{
if(possRow>numRows || possCol>numCols)
{
cout<<id<< " out of bounds-ignoring"<<endl;
}
else
{
replace(grid.at(possRow).front(),grid.at(possRow).back(),".",symbol.c_str());
}
locations>>possRow>>possCol>>symbol>>id;
}
}