获取2个字符串之间的字符串

Ben*_*Ben 4 c++ string

如何获取两个其他声明的字符串之间的字符串,例如:

String 1 = "[STRING1]"
String 2 = "[STRING2]"
Run Code Online (Sandbox Code Playgroud)

资源:

"832h0ufhu0sdf4[STRING1]I need this text here[STRING2]afyh0fhdfosdfndsf"
Run Code Online (Sandbox Code Playgroud)

我该"I need this text here"怎么办?

pol*_*nts 7

由于这是作业,只有线索:

  • 寻找index1发生的String1
  • 寻找index2发生的String2
  • index1+lengthOf(String1)(包含)到index2(独占)的子串是您所需要的
    • 如有必要,将其复制到结果缓冲区(不要忘记null终止)