If I have a textBox1 that contains 2 lines of text.

What I want to do is to put each line into an Array. So I want to check the textBox1
and read in all consisting lines into an Array.
(1 line will reprsent 1 memoryplace in the Array)

How is this possible. Will it work to do this ?

array<System::string ^> ^ Lines get(textBox1->Lines);

You can specify any delimiter you want.

Prototypes:

istream& getline (char* s, streamsize n);
istream& getline (char* s, streamsize n, char delim);
#include <iostream>
#include <fstream>
using namespace std;

const int MAXLINE=256;

int main()
{
   ifstream inFile ("test.txt");
   char oneline[MAXLINE];

   while (inFile)
   {
       inFile.getline(oneline, MAXLINE);
       cout << oneline << endl;
   }

   inFile.close();

   return 0;
}

This is reading from a file but you could change it to take input.

>What I want to do is to put each line into an Array.

array<System::String^>^ a =
  gcnew array<System::String^> ( textBox1->Lines->Length );

a = textBox1->Lines;

Great thanks for that. This works fine.

>What I want to do is to put each line into an Array.

array<System::String^>^ a =
  gcnew array<System::String^> ( textBox1->Lines->Length );

a = textBox1->Lines;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.