How to split strings? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to split strings?

example- string x="hello world"; I want to get the two words from the string separately so i can modify them then at the end of it all I want to place the modified words back into the string..How can i do that???

3rd Nov 2018, 5:35 AM
Mensch - avatar
3 Answers
+ 9
You can use strtok() like Jay Matthews said in C/C++ both. If you are using this function in C++ then you need to convert your string(string data type) to C-Style string(char array) using c_str() function.
3rd Nov 2018, 7:01 AM
blACk sh4d0w
blACk sh4d0w - avatar
+ 2
No, dont worry
3rd Nov 2018, 6:55 AM
Taste - avatar
+ 1
If i were to modify the part that i split in the string,would the original string value change too.
3rd Nov 2018, 5:49 AM
Mensch - avatar