給你個參考參考,寫的很不錯的,不過不是我寫的啦
#include
char* dstr(char* s, char c);
int main()
{
char str[1000];
char ch;
printf("請輸入一個字串:\t");
gets(str);
printf("請輸入要挖去的字元:\t");
scanf("%c",&ch);
puts(dstr(str,ch));
}
char* dstr(char* s, char c)
char* t = s;
char* f = s;
for(;*f;f++)
if(*f==c)
continue;
*t = *f;
t++;
*t = 0;
return s;
執行結果
給你個參考參考,寫的很不錯的,不過不是我寫的啦
#include
char* dstr(char* s, char c);
int main()
{
char str[1000];
char ch;
printf("請輸入一個字串:\t");
gets(str);
printf("請輸入要挖去的字元:\t");
scanf("%c",&ch);
puts(dstr(str,ch));
}
char* dstr(char* s, char c)
{
char* t = s;
char* f = s;
for(;*f;f++)
{
if(*f==c)
continue;
*t = *f;
t++;
}
*t = 0;
return s;
}
執行結果