我想要达到的结果
#include<stdio.h>
#include<stdlib.h>
void deletechar(char *str,char n)
{
char *head=str;
char *move=str;
while(move)
{
if( *move != n )
{
*head=*move;
head++;
}
move++;
}
*str='\0';
printf("%s",head);
}
int main()
{
printf("请从键盘中输入一个字符串\n");
char arr[10];
char c;
gets(arr);
printf("请输入要删除的字符\n");
scanf("%c",&c);
printf("删除后的字符串为:\n");
deletechar(arr,c);
system("pause");
return 0;
}
删除字符串中指定元素,此代码哪里出错了呀?