Hello,
I'm trying to read in words from a text file that look like:
The
World
Fell
Over
etc..
But it doesn't seem to be working.. I've written some code however it will only show the first word OR loads of question marks..
string dictionary()
{
string words[500];
ifstream openDictionary (dictLoc.c_str());
if(openDictionary.is_open())
{
for(int i=0; (i < !openDictionary.eof()); i++)
{
openDictionary >> words[i];
}
}else{
cout << "Cannot open the file";
}
return *words;
}
(Function for reading file / storing words)
string lines = dictionary();
for(int i=0; (i < 500); i++)
{
cout << lines[i];
}
(Code for displaying the different words)
Anyone have any ideas? Thanks