SKLAK SKLAK - 29 days ago 7
C++ Question

C++ How to get substring after a character?

For example, if I have

string x = "dog:cat";

and I want to extract everything after the ":", and return cat. What would be the way to go about doing this?

rcs rcs
Answer Source

Try this:

x.substr(x.find(":") + 1);