Originally Posted by
tharris7
Why use char arrays when c++ provides you with strings? Mixing up C and C++ is very confusing and will require a lot of casting. So what about something like:
string word = "abc";
string dictword;
ifstream dictionary("dictionary.txt");
while (getline(dictionary, dictword, ' '))
{
if (word == dictword)
cout << "found: " << word << "\n";
}
Off course you'll have to build in some error checking etc. And this code assumes that all words in textfile are delimited with a space. So some more work is required from you
Last edited by niek_e; May 11th, 2008 at 7:20 am.