1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
#include <iostream>
#include <string>
#include <fstream>
#include <cstdio>
using namespace std;
//takes files name and spell checks it
void spell (string Bonk)
{
string Bonkstring;
ifstream Bonkstream;
ifstream Dictionary;
Bonkstream.open("Bonk.txt");
Dictionary.open("Dictionary.txt");
while(!Bonkstream.eof())//loop runs through all words in dictionary text file
{
getline(cin, Bonkstring);
cout << Bonkstring;
}
}
void deletePunctuation(string &word, char punctuation)
{
int b_character(0);
b_character = word.find(punctuation);
while (b_character >= 0)
{
word.replace (b_character, 1, "");
b_character= word.find(punctuation);
}
}
//This function takes a word from input file stream and removes punctuation
void wordfilter(string& word) {
deletePunctuation(word, '(');
deletePunctuation(word, ')');
deletePunctuation(word, '!');
deletePunctuation(word, ',');
deletePunctuation(word, '.');
deletePunctuation(word, '"');
deletePunctuation(word, '\'');
}
/**************************************************************
* This function returns true if a word in input file stream *
* (i.e. bonk.txt) is in the dictionary, false otherwise. *
* @param word a string that contains a word to be checked *
* @return the Boolean status of the word (i.e. true or false) *
**************************************************************/
bool inDictionary(string word, string dictionary[198])
{
int index = 0;
bool in_boolean = false;
while (index < 198 && in_boolean == true)
{
in_boolean = strcmp(word, dictionary[index]);
index++;
}
return in_boolean;
}
/**************************************************************
* This is the main function of the program. *
* @return a value to terminate the program successfully *
**************************************************************/
int main ()
{
string Bonk;
string word;
char punctuation;
string Bonkfile;
cout<<"Enter the spell check file name"<<endl;
cin >> Bonkfile;
if (Bonkfile == "Bonk.txt")
{
deletePunctuation(word, punctuation);
spell(Bonk);
//another if in here for boolean
}
else
{
cout<<"That is not the correct file name. Enter again.";
cin>>Bonkfile;
}
return 0;
}
|