【发布时间】:2011-06-19 18:34:09
【问题描述】:
我正在使用 Visual C++ Express 2010...而且我对 C++ 非常陌生。
我想读取一个文件,然后删除单词“”之前的所有内容,然后用其余部分重写该文件。
这是我目前读取文件的代码:
#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;
}
非常感谢。
【问题讨论】:
-
“
<--START-->”是否保证是其行中唯一的东西? -
erm... 我可以这样 :) 但不希望这样
-
这两种方法都不难,但如果魔法词始终是唯一的选择,您就有更多选择。
标签: c++ visual-c++