Replacing strings in a vector

Alright I hav a program that readings from a txt file but is there a way to replace some of the words that get loaded into the vector so for example if the txt has a list of animals and i want to replace the word bird for book is their a way to do that

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#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();

	system("pause");
}
1
2
3
const std::string origin = "bird";
const std::string newword = "book";
std::replace(test.begin(), test.end(), origin, newword);


http://en.cppreference.com/w/cpp/algorithm/replace
Topic archived. No new replies allowed.