c++ - split a sentence so that adds each word in an array item -


I have a sentence, I want to break the sentence so that each word is added to an array item.
I have done this on the following code is still wrong.

  string str = "Welcome to the computer world."; String strands [5]; Small counter = 0; For (abbreviate i = 0; i & lt; str.length (); i ++) {strads [counter] = str [i]; If (str [i] == '') {counter ++; }}  

I am answering because you should learn from your mistakes: just Use + = string operator and your code will work:

  // strads [counter] = str [i]; & Lt; - Changing the strands [counter] + = str [i]; & Lt; - To remove this empty space (if you do not want to add them), just change the order of space probe, like something:  
 < For the code> (abbreviate i = 0; i & lt; str.length (); i ++) {if (str [i] == '') Counter ++; Other strads [counter] + = str; }  

Anyway, I'm suggesting to use duplicate links


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -