Code:
#include <stdio.h>
#include <stdlib.h>
void erase( char *str, char chr );
int main( void )
{
char test[] = "hello my brother's name is bob the builder!";
printf( "%s\n", test );
erase( test, 'b' );
printf( "%s\n", test );
getchar( );
return 0;
}
void erase( char *str, char chr )
{
int i, pos = 0;
for ( i = 0; str[i]; i ++ ) {
if ( str [i] == chr ) {
str[pos] = str[i + 1];
} else {
str[pos] = str[i];
pos ++;
}
}
str[pos] = '\0';
}
This erase function removes all occurances of a character from a string. When it encounters the character it simply overwrites it with the next character in the string. You might want to try indenting, and not using void main.
(edit: oops fixed a bug with erase).