Skip to content

Instantly share code, notes, and snippets.

@jshardy
Created February 26, 2019 09:15
Show Gist options
  • Save jshardy/9c71685784362971c59f767d53ab64fa to your computer and use it in GitHub Desktop.
Save jshardy/9c71685784362971c59f767d53ab64fa to your computer and use it in GitHub Desktop.
Remove Control Characters
/**********************************************************************
* Function: void remove_control_characters(char *str_line)
* implemented for good measure
* Purpose: remove all control characters from a string
* Precondition: pass a string
* Postcondition: all control characters removed from string
************************************************************************/
void remove_control_characters(char *str_line)
{
if(str_line != NULL)
{
while(*str_line != 0)
{
if(((*str_line >= 1) && (*str_line <= 31)) || (*str_line == 177))
*str_line = ' ';
str_line++;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment