📅  最后修改于: 2022-03-11 14:44:47.570000             🧑  作者: Mango
// CPP program to illustrate substr()
#include
#include
using namespace std;
int main()
{
// Take any string
string s = "dog:cat";
// Find position of ':' using find()
int pos = s.find(":");
// Copy substring after pos
string sub = s.substr(pos + 1);
// prints the result
cout << "String is: " << sub;
return 0;
}