07/07/20 13:15:02
>>363
#include <stdio.h> #include <string.h> #include <ctype.h>
#define SIZE 500
int main()
{ char English[SIZE] = {'\0'}; char Other[SIZE] = {'\0'};
char buff[SIZE]= {'\0'}; char *temp; int i,j=0,k=0; int len;
fgets(buff,sizeof(buff),stdin); if(temp = strchr(buff, '\n'))
*temp = '\0';
for(i = 0; buff[i] != '\0'; i++){
if(isalpha(buff[i]))
English[j++] = buff[i];
else
Other[k++] = buff[i];
}
printf("English %s Other %s \n",English,Other);
printf("英文字入力\n");
fgets(buff,sizeof(buff),stdin);
if(temp = strchr(buff, '\n'))
*temp = '\0';
printf("削除文字入力\n");
fgets(Other,sizeof(Other),stdin);
if(temp = strchr(Other, '\n'))
*temp = '\0';
len = strlen(Other);
while(temp = strstr(buff,Other)){
memcpy(temp,temp+len,sizeof(buff));
}
printf("削除後 %s \n", buff);
return 0;
}