어떻게 두 단어 사이에서 문자열을 반환합니까? 예를 들어 :두 단어 사이에서 문자열 가져 오기?
STARThello how are you doing today?END
출력은 다음과 같습니다
hello how are you doing today?
나는 항상 내가 그렇게 할 수있을 것입니다 방법에 대한 호기심이있었습니다.
std::string str = "STARThello how are you doing today?END";
const int startSize = 5; //or perharps something like startString.size()
const int endSize = 4; //or perharps something like stopString.size()
const int countSize = str.size() - (startSize + endSize);
std::string substring = str.substr(startSize, countSize);
은 문자열의 길이는 고정되어 참조? 'START'와'END'라는 단어가 고정되어 있습니까? 아니면'BEGIN'과'END'와 같은 다른 단어도 될 수 있습니까? –
아니요. START는 문자열이 시작되는 위치이고 END는 문자열이 끝나는 위치입니다. – okay14
아, 물론! 그것도 작동합니다. – okay14