removes all occurrences of the character ch from the string str: - C Function

C examples for Function:Utility Function

Description

removes all occurrences of the character ch from the string str:

void remove(char str[], int ch)
{
  int j, k;
  for(j = k = 0; str[j] != '\0'; j++)
    if(str[j] != ch)
       str[k++] = str[j];
  str[k] = '\0';
}

Related Tutorials