// 替换字符串中特征字符串为指定字符串int ReplaceStr(char *sSrc, char *sMatchStr, char *sReplaceStr){ int StringLen; char caNewString[MAX_MSG_LENGTH]; char *FindPos = strstr(sSrc, sMatchStr); if( (!FindPos) || (!sMatchStr) ) return -1; while( FindPos ) { memset(caNewString, 0, sizeof(caNewString)); StringLen = FindPos - sSrc; strncpy(caNewString, sSrc, StringLen); strcat(caNewString, sReplaceStr); strcat(caNewString, FindPos + strlen(sMatchStr)); strcpy(sSrc, caNewString); FindPos = strstr(sSrc, sMatchStr); } return 0;}