#include #include using namespace std; int main() { ofstream outputFile ; ifstream inputFile ; int number ; string word ; outputFile.open("data6.txt"); cout << "Now writing data to the file.\n"; // Write four names to the file. outputFile << "We are in a C++ class." << endl ; outputFile << "What" << endl ; outputFile << "fun." << endl ; outputFile.close() ; // Open the file. inputFile.open("data6.txt"); // If the file successfully opened, process it. if (inputFile) { cout << "Inside if condition." << endl ; inputFile >> word ; cout << word << endl ; inputFile >> word ; cout << word << endl ; inputFile >> word ; cout << word << endl ; getline( inputFile, word ) ; cout << word << endl ; // Close the file. inputFile.close(); } else { // Display an error message. cout << "Error opening the file.\n"; } //if return 0; } //main