#include <stdio.h>
#include <string.h>
int main(int argc,char **argv)
{
char test[100]="hello\r\nworld";
char *p = NULL;
printf("%s\n",test );
if( (p = strstr(test,"\r"))!=NULL)
*p = 0; //此时指针已经定位到了\r 暴力修改为hello0\nworld 然后就相当于截断了!strlen自动到0
printf("%s\n",test );
return 1;
}
hello
world
hello
[Finished in 0.9s]
这个比较优化了
现在写的是if== if== 不太好
这样可以截至字符串 消除收尾的\R\N