C++ ifstream read text file
#include <iostream> #include <fstream> #include <string> using namespace std; int main() /*from w w w .j av a2 s.c o m*/ { string word; ifstream infile("../MyFile.txt"); infile >> word; cout << word << endl; infile.close(); return 0; }