Hi,
I'm a beginner, so please forgive my inadequate knowledge.
I'm am trying to write a program that searches one file for specific words and their replacements found in another file. As of yet, all I have is a program that opens my files and counts the words in them. I think I need to put the words in a string array in order to search through them, but I don't know how to do this. If someone could help get me started on this part, I can play around with the rest of the program and hopefully have some luck.
Thanks

show us the code you have written so far. Do you know how to use vector class? That is the easiest array to use. You can make a vector of string objects

std::vector<std::string> theArray;

This is what I have so far, like I said, basically all it does is open the files and counts the words.

#include <iostream>
#include <string>
#include <fstream>
using namespace std;

int main () {

ifstream potterfile, keywordfile;
ofstream corrected;
string word, text, file[300];
int count;

count = 0;

//Open Potter text file, check if open
potterfile.open("potter.txt");
if (!potterfile.is_open()){
	cout << "Error, could not open the file" << endl;
	return -1;
}
//Count words in Potter text file
potterfile>>word;
while (!potterfile.eof()){
	count = count + 1;
	potterfile >> word;
}
cout <<"The number of words in the file is:" << count << endl;



//Open Keyword file check if open
keywordfile.open("keyword.txt");
if (!keywordfile.is_open()){
	cout << "Error, could not open the file" << endl;
	return -1;
}


return 0;

}

I am not familiar with the vector class string, but if you could elaborate on it a little I may be able to figure it out.
Thanks

This question has already been answered. Start a new discussion instead.