用C++怎么读取txt文件 并能够只用文件中的内容
希望能举个例子
程序代码:#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream in("abc.txt");
string line;
int num = 0;
while (getline(in, line))
{
cout << ++num << "\t:" << line << endl;
}
return 0;
}