在我现在正在处理的代码中,我有一个向量从txt文件加载,现在我试图查看它们是否可以替换矢量中某些单词而不需要位置或任何
因此,例如,如果TXT含有动物名单,我想换鸟的书怎么会怎么做,如果没有需要的字母位置替换矢量中的字符串而没有定位
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
using namespace std;
vector <string> test;
int main()
{
string file;
fstream fout("Vector.txt");
while (!fout.eof())
{
getline(fout,file);
test.push_back(file);
}
fout.close();
for(int i = 0; i < test.size(); i++)
{
cout << test[i] << endl;
}
system("pause");
}
TXT包含:
狗
猫
鸟
河马
狼
目前还不清楚是什么你在测试[I](一个词,一个句子?)。 – Kiroxas
可能重复的[尝试替换字符串中的单词](http://stackoverflow.com/questions/9053687/trying-to-replace-words-in-a-string) –
可以发布一个输入txt示例和一个可能产出预期?我无法理解你想要做什么。 – hidrargyro