File Read
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main ()
{
/* ifstream class is used to read from files */
string line;
ifstream newFile ("sample.txt");
if (newFile.is_open())
{
while ( getline (newFile,line) )
{
cout << line;
}
newFile.close();
}
else cout << "Unable to open file";
return 0;
}
Output:
HELLO WORLD..!!