Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //g++ 4.6.1编译通过!
- #include <fstream>
- #include <iostream>
- #include <algorithm>
- #include <iterator>
- #include <string>
- int main(int argc, char** argv)
- {
- using namespace std;
- if (argc!=2)
- {
- clog << "\t防河蟹——空格、制表符替换程序" << endl;
- clog << "用法:" << argv[0] << " 程序名" << endl;
- clog << "在Windows下,您可以简单的将所需替换的原代码文件拖到本程序上" << endl;
- return 1;
- }
- ifstream fileIn(argv[1]);
- if (!fileIn.is_open())
- {
- cerr << "打开文件失败!" << endl;
- return 1;
- }
- string filename(argv[1]);
- filename.insert(filename.rfind('.'), ".Modified");
- ofstream fileOut(filename.c_str());
- for (istreambuf_iterator<char> ibeg(fileIn), iend; ibeg != iend; ++ibeg)
- {
- switch (*ibeg)
- {
- case ' ':
- fileOut << " ";
- break;
- case '\t':
- fileOut << "    ";
- break;
- default:
- fileOut << *ibeg;
- break;
- }
- }
- clog << "目标文件“" << filename << "”已生成!" << endl;
- clog << "替换完成!" << endl << "请使用贴吧经典版发帖!" << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement