我正在使用Visual C++ Express 2010 ...而且我对C++很新.
我想读取一个文件,然后删除"< - START - >"之前的所有内容,并用其余文件重写该文件.
这是我到目前为止阅读文件的代码:
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream myReadFile;
myReadFile.open("text.txt");
char output[500];
int found;
int line;
if (myReadFile.is_open()) {
line = 0;
while (!myReadFile.eof()) {
myReadFile >> output;
if(line > 20) {
cout << output;
}
line++;
}
}
myReadFile.close();
system("PAUSE");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
提前谢谢了.