I am trying to open a file on my computer using the following code:
but the file does not open. Where is my error? What am I doing wrong?. . . . therryCode:ifstream a_file ( "D:\LotteryPrograms\Mega_Mill.txt" ); //Opens Mega_Mill for reading the file while ( !a_file.is_open() ) { if ( !a_file.is_open() ) // Checks to make sure Mega_Mill file is open and ready to be used. { cout << " The file could not be opened" << endl << endl; cout << "Please wait while we try to open the file." << endl << endl; for (int i; i <= 2; i++); (a_file.open("D:\LotteryPrograms\Mega_Mill.txt")); // If Mega_Mill file is not open, // it opens it. cin.get(); // it waits for a key stroke so we can read the comments. } else { cout << "It's OK, the file is open" << endl << endl; // This tells up that its ok // to use the file. cin.get(); // it waits for a key stroke so we can read the comments. } }