40)//将字符串中的||去掉
#include<stdlib.h>
#include<stdio.h>
#include <string.h>
#include <math.h>
int main(int argc,char **argv)
{
char temp[10];
char *haystack="aaa||a||bbb||c||ee||";
char *needle="||";
char* buf = strstr( haystack, needle);
while ( buf != NULL )
{
// buf[0]=”; 替换为
strncpy(temp, haystack, buf-haystack);
temp[buf-haystack] =0;
printf( "%s\n", temp); //haystack);
haystack = buf + strlen(needle);
/* Get next token: */
buf = strstr( haystack, needle);
}
return 0;
}