I have provided the code I have written. All I need you to do is to rewrite the code. I need you to rewrite the comments, rename all the variables, and shift the code. It should look different once you have edited it. I would like to see another format for this code. It is in C-Programming. I think it shouldn’t take so long. Take your time, please! I really appreciate any help you can provide! CODE STARTS HERE: #include #include #include int main(int argc, char* argv[]){ printf("Entered String is: %s\n", argv[1]); const char *original_str = argv[1]; int i = 0, j = 0; int err_flag = 0; char num_arry[10] = {'0','1','2','3','4','5','6','7','8','9'}; /*if string conatins a digit in it return error, simple linear search has been used*/ for(i=0;i<10;i++){ for(j=0;j
2. I have provided the code I have written. All I need you to do is to rewrite the code. I need you to rewrite the comments, rename all the variables, and shift the code. It should look different once you have edited it. I would like to see another format for this code. It is in C-Programming. I think it shouldn’t take so long. Take your time, please! I really appreciate any help you can provide!
CODE STARTS HERE:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(int argc, char* argv[]){
printf("Entered String is: %s\n", argv[1]);
const char *original_str = argv[1];
int i = 0, j = 0;
int err_flag = 0;
char num_arry[10] = {'0','1','2','3','4','5','6','7','8','9'};
/*if string conatins a digit in it return error, simple linear search has been used*/
for(i=0;i<10;i++){
for(j=0;j<strlen(original_str);j++){
if(original_str[j] == num_arry[i]){
printf("error\n");
err_flag = 1;
break;
}
}
if(err_flag)
break;
}
/*If error doesn't have digit then it will for compression phase*/
if(!err_flag){
char *input = argv[1];
int n = strlen(input);
char *compressed_str = (char*)malloc(sizeof(char)*(n*2+1));
for(i=0; i<n; i++) {
int counter = 1;
while (i < n - 1 && input[i] == input[i+1]) {
counter++;
i++;
}
printf("%c%d", input[i],counter);
}
printf("\n");
}
return 0;
}

Below is the required code and sample output:
Step by step
Solved in 3 steps with 1 images









