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 Nick Evan; May 11th, 2008 at 7:20 am.
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Offline 4,132 posts
since Oct 2006