/* 删除文本文件中所有以"//"开头字符串的C++程序。 -------------------------------------------------------------------------------- */ #include <fstream> #include <iostream> using namespace std; /******************** argument count 参数个数 argument values 参数值 ************/ void main(int argc,char* argv[]) { ifstream infile; ofstream outfile; char ch; int flag=0; if (argc < 3) { cout << "Error,You shall use this programs as:/n/t" << "purgefile filename1 filename2" << endl; exit(0); } infile.open(argv[1]); if (!infile) { cout << "input file error" <<endl; exit(0); } outfile.open(argv[2]); if (!outfile) { infile.close(); cout << "output file error" <<endl; exit(0); } while (infile.get(ch)) { if (ch=='/') { infile.get(ch); if (ch=='/') { continue; } outfile.put('/'); } outfile.put(ch); } infile.close(); outfile.close(); }