定义整型变量出了点问题,deleteChar函数中四个整型变量报错
删除一个字符串中的指定字母,deleteChar函数中四个整型变量报错,求解程序代码:
#include<stdio.h> #include<stdlib.h> #include<string.h> char *deleteChar(char *str,char *Delete) { int hash[256]; if(Delete==NULL) return str; int i,j,k; for(i=0;i<256;i++) //给hash数组赋初值 hash[i]=0; for(j=0;j<strlen(Delete);j++) //将要删除的字符对应的ASCII码对应的数组赋值1 hash[Delete[j]]=1; int count; for(k=0;k<strlen(str);k++) //查找目标字符串,并删除 if(hash[str[k]]==0) { str[count]=str[k]; count++; } str[count]='\0'; return str; } int main() { char *str,*Delete; printf("输入目标字符串:\n"); scanf("%s",str); //输入目标字符 printf("输入要删除的字符:\n"); scanf("%s",Delete); //输入要删除的字符 deleteChar(str,Delete); printf("结果为:"); printf("%s",str); }