dimanche 21 août 2016

Split input string into tokens delimited by ',' and store those tokens in array

Input string contains comma separated names and it is separated into two parts by '#'. I want to be able to extract names from the string and store them in two different places (preferably arrays).

String example: Google,Microsoft,Amazon#Search,Windows,Cloud

Output should be two arrays:

Array 1: {Google, Microsoft, Amazon}
Array 2: {Search, Windows, Cloud}

I'm aware that this task is easily done in Java but I want to do the same task with ease and simplicity with C++. I'm lacking comprehensive knowledge of in-built string functions available in C+11. Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire