Question
Please help these are 2 C++ functions and I need these functions to C I need this all C++ code converting to C Please convert
Please help
these are 2 C++ functions and I need these functions to C
I need this all C++ code converting to C
Please convert this code to C
The code for the my-zip program is:
#include
void runlength_encoding(string content){ int size_ = content.length(); // size of the content in files
// the function uses simple logic to count continuous occurences of all characters and print them in standard output for (int i = 0; i < size_ ; i++) { char cur_char = content[i]; int count = 1; while (i < size_ - 1 && content[i] == content[i + 1]) { count++; i++; } // writing in binary using fwrite fwrite(&count , sizeof(int) ,1 , stdout ); cout< int main(int argc, char **argv){ if(argc<=1){ // incase no file is specified following the guide lines mentioned cout<<"my-zip:file1[file2..] "; exit(1); } string all_content = ""; for(int i = 1; i The code for th my-unzip is: #include int main(int argc, char **argv){ if(argc<=1){ // incase no file is specified cout<<"my-unzip:file1[file2..] "; exit(1); } FILE *fp; // file pointer fp = fopen(argv[1], "rb"); if(fp == NULL) { // in case the file does not exist printf("Error opening file "); exit(1); } //runlength_decoding int count; char c; while(fread(&count , sizeof(int), 1 , fp) == 1){ fread(&c , sizeof(char), 1 ,fp); // reading character and the number of times it occurs continuously in c and count // then printing it that many times in standard output console for(int i=0;i return 0; }
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