How to split a string in an array using c++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

How to split a string in an array using c++?

Java, Javascript, python, etc languages have split method for splitting a string into array but I am surprised that c++ doesn't have. Can anyone please explain me how can I do this. (I searched on google but I can't understand anything).

20th May 2018, 7:07 PM
Vikash Pal
Vikash Pal - avatar
1 Answer
+ 8
You could use the string class to get some useful methods and subclass it so you can extend with a split. It has find and substring methods. You could parse the character array and write a split from scatch. This is how I'd do it.
20th May 2018, 8:18 PM
John Wells
John Wells - avatar