|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
void del_char(char *p, char n);
int main()
{
char s;
//static char shuzu[20] = "i have 90 students";
static char *p2= "i have 90 students";
//char *tr = shuzu;
char *tr = p2;
printf("please input delchar:");
s = getchar();
printf("tr :%p\n", tr);
del_char(tr, s);
printf("the string is:%s\n", tr);
}
void del_char(char *t, char n)
{
char *p=t;
char l;
l = 0;
//printf("p:%p\n", p+1);
for (; *t != '\0'; t++)
{
if (*t != n)
{
l = *t;
*p++ = l;// 此处出现错误
}
}
//*p1 = '\0';
//printf("the new is %s\n", p1);
}
|
|