deeporist
2016-12-09 15:09:57 +08:00
'''
#include <stdio.h>
int main()
{
char sa[]="abcaa63akdfk";
char sb[]="ayk5";
void fun(char *,char *);
printf("%s\n%s\n",sa,sb);
fun(sa,sb);
printf("%s\n%s\n",sa,sb);
return 0;
}
void fun(char *s1,char *s2)
{
char *p0,*p1,*p2;
p0=p1=s1;
char c=0;
while(*p0)
{
p2=s2;
while(*p2 && (*p0!=*p2))
p2++;
if(*p2=='\0')
*p1++=*p0;
p0++;
}
*p1='\0';
}
'''
win8.1 cygwin gcc 编译成功运行成功结果无误 gdb 完全调试
ps :我一开始把那两字符串声明成了指针类型(char *sa="abcaa63akdfk") 然后 segmentation fault 了一下午..........神 tmC 陷阱白看了 我今年也报了名我看我还是先去面壁比较好