Scene:
1. Merge text files, and do not merge the first line from the 2nd file.
2. Add a feature that supports more than 2 file merges.
3. Question: http://ask.csdn.net/questions/192151
Just can say very easy: the foundation is just off, this classmate, also may not develop, put here also for training Foundation poor.
Test.cpp
#include <fstream> #include <string> #include <iostream>using namespace std;//The last parameter is the output file.// Support for extra 2 files Merge//use method, command line: Test.exe 1.txt 2.txt output.txtint Main (int argc, char const *argv[]) {cout << usage1:t Est.exe 1.txt 2.txt output.txt "<< endl;cout <<" Usage2:test.exe 1.txt 2.txt ... output.txt "<< endl;if (argc <= 3) return-1;bool first_line_readed = False;ofstream fout (argv[argc-1], ios::out); for (int i = 1; i< argc- 1; ++i) {ifstream fin (argv[i]), string str;int Line_number = 0;while (Getline (FIN,STR)) {if (!line_number) {if "!first_line_ readed) {first_line_readed = True;str.append ("\ n"); Fout.write (Str.c_str (), str.size ());}} Else{str.append ("\ n"); Fout.write (Str.c_str (), str.size ());} line_number++;}} cout << "Finish ..." << argv[argc-1] << endl;return 0;}
[C + + standard library]_[0 base]_[using FStream to merge text files]