//读取文件中的数据,并输出 #include "stdafx.h" #include <fstream> #include <iostream> #include <string> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { ifstream in("d://1.txt",fstream::in | fstream::out ); string str; in >> str; //仅仅能读取其中的一行数据 cout << str << endl; return 0; }