Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

you need to write a C function named rem. The prototype is: int rem(char*, char*

ID: 3601617 • Letter: Y

Question

you need to write a C function named rem. The prototype is: int rem(char*, char*); The function accepts 2 strings: the first is a string of text to process; the second is where the output will be placed. rem() should remove all occurrences of a lowercase 'x' from the first string, and save the resulting string in the second arg. You may use the strlen() function; no other built-in fuctions should be used. Test your program thoroughly. Then, once you are convinced that it works, compile and assess it as follows:

Explanation / Answer

#include <stdio.h>
#include <string.h>
int rem(char*, char*);
int main()
{
char a[50] = "aadsfasdxasdxxsxSXFEFWEx";
char b[50];
rem(a,b);
printf("Result: %s ", b);
return 0;
}
int rem(char *a, char *b) {
int i, j,l = strlen(a);
for(i=0,j=0;i<l;i++) {
if(a[i] != 'x') {
b[j++] = a[i];
}
}
  
}

Output: