std :: string의 replace를 사용하려고했지만 성공적으로 수행 할 수 없었습니다.std :: string이 시작과 끝 사이를 바꿉니다
나는 약간의 교체를하고 싶은 큰 문자열이 있습니다. 새 문자열로 대체해야하는 부분 문자열의 시작과 끝을 알고 있습니다.
static void replaceString(string &input, const string &startString, const string &endString, const string &replacement)
{
size_t indexStart, indexEnd;
indexStart = input.find(startString);
indexEnd = input.find(endString);
if (indexStart != xml.npos) {
input.replace(indexStart, indexEnd-indexStart, replacement);
}
}
마지막에는 입력이 변경되지 않습니다.
여기서 내가 뭘 잘못하고 있니?
감사
(indexStrat! = xml.npos) if line if if line. –
함수에 어떤 입력 사항이 있습니까? 그리고 만약'endString'을 찾을 수 없다면? –
xml은 오타였습니다. 입력입니다. – chingupt