void CompressFile(){ Encoding inputFile; cout << " What is the file name? " << endl; string inputFileName = GetLine(); ibstream infile; infile.open(inputFileName.c_str()); if (infile.fail()) Error("Can't open input file!"); cout << " What do you want to name the compressed file? " << endl; string newFileName = GetLine(); obstream outfile; outfile.open(newFileName.c_str()); if (outfile.fail())Error("That is not a valid file name"); inputFile.compress(infile, outfile); }
int main() { string command; ibstream infile; obstream outfile; Encoding huffman; while(true){ infile.clear(); outfile.clear(); getLine("compress(c) or decompress(d)", command); if(command == "c"){ huffman.compress(infile, outfile); }else if(command == "d"){ huffman.decompress(infile, outfile); }else if(command == "exit") break; else{ cout << "invalid command" << endl; } } return 0; }