Oddbean new post about | logout
 
	


#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
int main(void)
{
	// input the file name of the text file to be read into a string
	string filename = "input.txt";

	// open an ifstream object and set it to read from the file named in filename
	ifstream myFile(filename);

	// check whether the file was opened successfully
	if (myFile)
	{
		// read everything from the input file into a string
		string text = myFile.rdbuf();

		// output the contents of the text
		cout << text << endl;
	}
	else
	{
		// output an error message if the file could not be opened
		cout << "Could not open input file." << endl;
	}

	myFile.close(); // close the ifstream object
	return 0;
}

/anna