35 lines
850 B
C++
35 lines
850 B
C++
|
#include <iostream>
|
||
|
#include <fstream>
|
||
|
#include "coding.h"
|
||
|
|
||
|
int main (int argc, char* argv[]) {
|
||
|
std::string filename;
|
||
|
|
||
|
if (argc > 1) {
|
||
|
filename = argv[1];
|
||
|
} else {
|
||
|
std::cout << "Enter filename: ";
|
||
|
std::cin >> filename;
|
||
|
}
|
||
|
|
||
|
std::ifstream infile(filename, std::ios::binary);
|
||
|
if (!infile) {
|
||
|
std::cerr << "Could not open file " << filename << "\n";
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
std::string output_filename = filename + ".enc";
|
||
|
std::ofstream outfile(output_filename, std::ios::binary);
|
||
|
if (!outfile) {
|
||
|
std::cerr << "Could not create output file" << "\n";
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
unsigned char c;
|
||
|
while (infile.get(reinterpret_cast<char&>(c))) {
|
||
|
outfile.put(encode(c));
|
||
|
}
|
||
|
|
||
|
std::cout << "Encoding complete. Output saved to " << filename << "\n";
|
||
|
return 0;
|
||
|
}
|