How to write code for separating words from a string ?
May I know how to write a c++ program where a string value is to be read in from the keyboard and the program should generate an output in the following format :
Example : Mr Brown*246 The Park Building*Neopets Area*Country
Output :
Mr Brown
246
The Park Building
Neopets Area
Country
May I know what code to use to write the above program? I did try to use 'strtok' to write but it only return to a new line whenever it see a spacing and not a * .
Can anyone please enlightened me on this problem ?
Thank You.
Re: How to write code for separating words from a string ?
Quote:
Originally posted by dingtang
Example : Mr Brown*246 The Park Building*Neopets Area*Country
Output :
Mr Brown
246
The Park Building
Neopets Area
Country
Try using the CString class, itt'l make things a lot easier for you.