#include #include #include #define TRUE 0 #define FALSE -1 char* rmvchar(char ch, char* string); void main(void){ char str[48]; printf("** TESTRMV2: 文字の除去 **\n"); getchar(); strcpy(str, "ASIA AMERICA JAPAN"); printf("%s から文字 A だけを除去します。 \n", str); getchar(); strcpy(str, rmvchar('A', str)); printf("==> 結果は %s です。 \n", str); getchar(); } /***********************************/ char* rmvchar(char ch, char* string) /***********************************/ { char* ptr; int pos; while((ptr = strchr(string, ch)) != NULL){/*while*/ pos = (int)(ptr - string); strcpy(&string[pos], &string[pos+1]); }/*while*/ return string; }