I have a string in the following format <a,b> which represents an edge in a directed graph (a is source and b is target) where 'a' and 'b' are also string themselves (for example a can be "Square" and b is "Circle").
I need to build a function which extracts a and another one which extracts b.
so the signature will be:
string getSource(String edge); //will return b
string getTarget(String edge); //will return a
I am using the std::string library to represent those strings.
I know that I need to find a way to find the ',' separating them in the middle of the string, and get rid of the '<' and'>'. But I couldn't find a function in std::string that will help me to do that.
How would you go about on doing this?
Thank you!
Aucun commentaire:
Enregistrer un commentaire