My file is not working and reading the context from the file in C++ : <p>I tried to open a certain file and read the content to put it into a string named letters but then every time I typed the file name I keep getting error can't find open the file.</p>

<p>void createTree()
{</p>

<pre><code>BTS tree;
string filename;
string letters;
ifstream file;
int input = 0;

cout&lt;&lt;"Enter the file name:  ";     // ask the user to input the file name
cin &gt;&gt;filename; //input the user input into filename

file.open(filename.c_str());
if(file)
{
    cout&lt;&lt;"File is open";
    while(!file.eof())
    {
        cout&lt;&lt; "In the while loop"&lt;&lt;endl;
        getline(file, letters);
        tree.insertWord(letters);
    }
}

else
      cout&lt;&lt;"Error can't open the file"&lt;&lt;endl;
tree.printTree();

file.close();
</code></pre>

<p>}</p>
