char* delchar(char *str,char c) { char *p,*p2; p=str; while(*p) { if(*p==c) { p2=p; while(*(p2+1)) { *p2=*(p2+1); p2++; } *p2='\0'; } p++; } *p='\0'; return str; }
#include <stdio.h> void foo( char* s, char c ) { char* p = s; for( ; *s; ++s ) if( *s != c ) *p++ = *s; *p = '\0'; } int main( void ) { char s[81], c; fgets( s, sizeof(s), stdin ); scanf( " %c", &c ); foo( s, c ); printf( "%s", s ); }