Question
In C++ read.cpp #include #include using namespace std; int main(int argc, char *argv[]){ unsigned char ch; ifstream in(argv[1],ios::in|ios::binary|ios::ate); size_t size = 0; // here size
In C++
read.cpp
#include decode.cpp #include int strchr(unsigned char s[], unsigned char c) { int i=0; while(s[i]!=c) i++; return i; } treenode * treebuild(unsigned char pre[], unsigned char in[], int & pos, int size) { if (size==pos) return NULL; treenode *t = new treenode; t->data = pre[pos]; t->left = NULL; t->right = NULL; int loc = strchr(in, pre[pos++]); in[loc] = 0; if (loc > 0 && in[loc-1] != 0) t->left = treebuild(pre, in, pos, size); if (loc right = treebuild(pre,in,pos, size); return t; } void parse(string c, treenode *t) { treenode *p = t; for(int pos=0; pos left : p->right; if (p->left == NULL) { cout data; p = t; } } } int main(int argc, char* argv[]) { ifstream prefile(argv[1],ios::in|ios::binary|ios::ate), infile(argv[2],ios::in|ios::binary), codefile(argv[3]); size_t size = 0; // here size = prefile.tellg() ; // get the length of the file prefile.seekg(0, ios::beg); // set the pointer to the beginning unsigned char *pre = new unsigned char[size], *in = new unsigned char[size]; for (int i =0; i decodebin.cpp #include int strchr(unsigned char s[], unsigned char c) { int i=0; while(s[i]!=c) i++; return i; } treenode * treebuild(unsigned char pre[], unsigned char in[], int & pos, int size) { if (size==pos) return NULL; treenode *t = new treenode; t->data = pre[pos]; t->left = NULL; t->right = NULL; int loc = strchr(in, pre[pos++]); in[loc] = 0; if (loc > 0 && in[loc-1] != 0) t->left = treebuild(pre, in, pos, size); if (loc right = treebuild(pre,in,pos, size); return t; } void parse(string c, treenode *t,short count) { treenode *p = t; for(int pos=0; pos left : p->right; if (p->left == NULL) { cout data; p = t; if(--count == 0) return; } } } int main(int argc, char* argv[]) { ifstream prefile(argv[1],ios::in|ios::binary|ios::ate), infile(argv[2],ios::in|ios::binary), codefile(argv[3],ios::in|ios::binary|ios::ate); size_t size = 0; // here size = prefile.tellg() ; // get the length of the file prefile.seekg(0, ios::beg); // set the pointer to the beginning unsigned char *pre = new unsigned char[size], *in = new unsigned char[size]; for (int i =0; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started