There is a string of type string with three words separated by spaces. How can I break it and put all three words in an array?

  • According to the rules of the forum, the questions should not be reduced to the decision or the completion of educational tasks for students. Please clarify what you have done yourself and what did not work out. - Zufir

2 answers 2

The algorithm is as follows:

In the for loop, you go along the line when you find a space - this means that you have found the end of the word. You put this word (from the previous space or the beginning of a line to this space) into an array and so on until the end of the line.

  • @ 4per, as I recall, there is no such thing as a dynamic array in pascal ... Therefore, if you want dynamics, then you need to make a list. - iluxa1810 1:51
  • In pascalabc there is exactly a dynamic array - user31238
  • @ user31238, if I'm not mistaken, then pascalabc is not canonical pascal. 2-3 years ago, the canonical pascal was taught. - iluxa1810
  • So it is, in pascalabc.net there are a lot of non-canon chips. - user31238

In PascalABC.Net, this is done in one action:

 var Words := txtString.toWords(' '); 
  • one
    PascalABC.Net and Pascal are the same different languages ​​as VB.Net and VB. - 4per