34 lines
No EOL
822 B
C++
34 lines
No EOL
822 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 to decode: ";
|
|
std::cin >> filename;
|
|
}
|
|
|
|
std::ifstream infile(filename, std::ios::binary);
|
|
if (!infile) {
|
|
std::cerr << "Could not open file " << filename << "\n";
|
|
return 1;
|
|
}
|
|
|
|
std::ofstream outfile(filename + ".dec", 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(decode(c));
|
|
}
|
|
|
|
std::cout << "Decoding complete. Output saved to " << filename << ".dec" << "\n";
|
|
return 0;
|
|
} |