#include
int main()
{
char A[100];
scanf("%s",A);
printf("\n");
for (int i=0;A[i] != '\0';i++)
{
for (int j=0;A[j]!='\0';j++)
{
if (j == i)
continue;
printf("%c",A[j]);
}
printf("\n");
}
return 0;
}
截图如下:
/*
源串是:1232254682
待删除字符是:2
删除(2)后是:135468
Press any key to continue
*/
#include
#include
char *delchar(char *s, char c_h) {
char *p,*q;
for(p = s;*p; ++p) {
if(*p == c_h) {
q = p;
while(*q = *(q + 1)) q++;
p--;
}
}
return (s);
}
int main() {
char s[80];
char *p,c;
printf("源串是:");
gets(s);
printf("待删除字符是:");
c = getchar();
p = delchar(s,c);
printf("删除(%c)后是:%s\n",c,p);
return 0;
}