Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main(int argc, char **argv) {
- system("cls");
- if(argc >= 3){
- const char *input_file = argv[1];
- ofstream o_fp;
- ifstream i_fp;
- int split_count = argc - 2;
- i_fp.open(input_file, ios::binary);
- i_fp.seekg(0, ios::end);
- int in_size = i_fp.tellg();
- i_fp.seekg(0, ios::beg);
- int limit = in_size / split_count;
- int i = 2;
- o_fp.open(argv[i], ios::binary);
- for(int j = 1; j <= in_size; j++){
- if(j % limit == 0){
- i = i + 1;
- o_fp.close();
- o_fp.open(argv[i], ios::binary);
- }
- o_fp.put(i_fp.get());
- }
- o_fp.close();
- i_fp.close();
- cout << split_count << " output file(s) created successfuly!" << endl;
- o_fp.close();
- return 0;
- }
- else {
- cout << "In-sufficient number of arguments" << endl;
- cout << "USAGE: File4.exe in_file1 out_file1 [out_file2 ...]" << endl;
- return 1;
- }
- }
Add Comment
Please, Sign In to add comment