-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
40 lines (35 loc) · 973 Bytes
/
main.cpp
File metadata and controls
40 lines (35 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* main.cpp
* Daniel Jarka
* 11/11/24
*
* CS 15 Project 3 Zap
*
* This file contains the driver that allows the user to create an instance
* of a HuffmanCoder and run it. To use the HuffmanCoder, the client must
* enter either "zap" or "unzap" to encode or decode respectively. If an
* incorrect command or number of arguments is entered, the program will print
* to cerr the correct usage of the ./zap program.
*
*/
#include <iostream>
#include <fstream>
#include <string>
#include "HuffmanCoder.h"
using namespace std;
int main(int argc, char *argv[])
{
HuffmanCoder coder;
std::string command = argv[1];
if (command == "zap" and argc == 4) {
coder.encoder(argv[2], argv[3]);
}
else if (command == "unzap" and argc == 4) {
coder.decoder(argv[2], argv[3]);
}
else {
cerr << "Usage: ./zap [zap | unzap] inputFile outputFile" << endl;
return EXIT_FAILURE;
}
return 0;
}