Read text from Text Editor into Array of Strings

Hi

I wanted to read a text from the notepad into the array of strings. I referred to a document online where it explained how to get text from editor into file. Is there a way to get it into array instead of file?

Thanks.

StringArray::addTokens() ?

I tried

String abc = texteditor->getText();

But the issue is I don’t know how to convert juce::String to std::string. I need to pass the editor text into C++ function.

I will try with your suggestion.

I tried using StringArray::addTokens. But it breaks the string into two and adds only one substring to the array.

E.g. CMDString = “Hi, my name is Tom. \n What are you doing? \n How are you?\n Add string to array\n”

string_array.addTokens(CMDString, “\n”, " ");

it adds “Hi, my name is Tom. What are you doing?” into the array .

Could you point out my mistake?

The help for the function is pretty clear, isn’t it? You seem to be misunderstanding the last parameter.

also, if you’re adding tokens separated only by newlines, addLines() might be a little easier

I tried using addLines() before addTokens but same issue.

Got it. Its working fine now.

Thanks for your help.