#include <iostream>
#include <fstream>
#include <vector>
#include <string>
int main() {
std::ifstream file("file.txt"); // Open file named "file.txt"
std::vector<std::string> lines; // Create a vector to store lines from the file
std::string line; // Create a string variable to hold each line
if (file.is_open()) { // Check if the file is open
while (std::getline(file, line)) { // Read lines from the file into 'line'
lines.push_back(line); // Add 'line' to the vector 'lines'
}
file.close(); // Close the file
} else {
std::cout << "Unable to open file"; // Display error if file cannot be opened
}
// Display the contents of the vector 'lines'
for (const auto &l : lines) {
std::cout << l << std::endl;
}
return 0;
}