I am trying to write a program that reads from a file, puts the words into an array counts how many times each word appears in the file, alphabetizes it and then prints the output to an output file. But when I run it is say .exe has stopped working windows is looking for a solution. I know it is opening the file, reading from it and putting into an array but I haven't been able to test if it has counted and alphabetized because of this error. Can you please see where I went wrong?
//============================================================================
// utilities
//============================================================================
string NumberToString ( int Number )
{
ostringstream ss;
ss << Number;
return ss.str();
}
//take 1 line and extract all the tokens from it
//feed each token to processToken... for recording
void extractTokensFromLine(std::string &myString) {
const char CHAR_TO_SEARCH_FOR = ' ';
stringstream ss(myString);
string tempToken;
//============================================================================
// main please do not return magic numbers, look at the constants above for
// appropriate values
//============================================================================
int main() {
std::string myFileName = "TestData.txt";
ifstream myfile;
//string words[100];
while(true)
{
if (openFile(myfile,myFileName)==true)
{
std:: string line;
while(!myfile.eof())
{
getline(myfile,line);
extractTokensFromLine(line);
//cout<<line;
}
closeFile(myfile);
break;
}
else {
cout<<"Unable to open file. Please enter a new one or enter x to close the program"<< endl;
cin >> myFileName;