int main(int argc, char *argv[])
{
unsigned char indx = 0;
if (argc != 3)
{
printf("Invalid No. of arguments passed");
return 0;
}
char result[255] = {'\0'};
char *input = argv[1];
char rmchar = *argv[2];
while(*input)
{
if (*input != rmchar)
{
result[indx++] = *input;
}
input++;
}
printf("%s",result);
return 0;
}
This code is working and giving expected result.
input - $ ./a.out abcd:abcd:abcd :
output - $abcdabcdabcd
Here punctuation is semicolon :