How to separate the fullname "John Doe" and assign "John" to firstname and "Doe"to lastname? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to separate the fullname "John Doe" and assign "John" to firstname and "Doe"to lastname?

separating fullname in firstname and lastname

22nd Sep 2018, 12:35 AM
Tom
Tom - avatar
2 Answers
22nd Sep 2018, 12:39 AM
Toni Isotalo
Toni Isotalo - avatar
+ 4
You can use strtok function for that http://www.cplusplus.com/reference/cstring/strtok/ Since strtok is a C language function so it handles character array not strings. To convert string into char array use (string).c_str function http://www.cplusplus.com/reference/string/string/c_str/
22nd Sep 2018, 11:05 AM
blACk sh4d0w
blACk sh4d0w - avatar