title: How to store adresses in an array - C++?
body: <pre><code>My Code example:
  
  char* array = new char[10];
  char* str;
  int j = 0;
  
  MyClass(char* input){                  //input = sentence columns terminated by '\n'
  
     str = new char[strlen(input)];
  
     for(int i=0; i&lt;strlen(input); i++){
        if (input[i] == '\n'){           //look for end of line
           str[i] = '\0';                //add \0 Terminator for char[]
           array[j] = &amp;(str[i]);         //store address of sentence beginning in array
           j++;
        }
        else{
           str[i] = input[i];
        }
     }
  }
  </code></pre>
  
  <p>How do i store an address into an array. So i can get the beginning address of a sentence by number. I created a solution with a vector storing my sentences as char* objects. But there must be a way without vectors?!</p>
  
  <p>EDIT:</p>
  
  <p>This is my solution.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  class Pointer{
  
  public:
  
      char** array = new char*[10];
      char* str;
      char* buffer;
      int j = 1;
  
      Pointer(char* input){
          str = new char[strlen(input)];
          array[0] = str;
          for (int i = 0; i &lt; strlen(input); i++){
              if (input[i] == '\n'){
                  str[i] = '\0';
                  array[j] = &amp;(str[i]) + sizeof(char);
                  j++;
              }
              else{
                  str[i] = input[i];
              }
          }
      }
  
      void output(int i){
          buffer = array[i];
          cout&lt;&lt;buffer;
      }
  };
  </code></pre>
  
  <p>Thanks for your help! :)</p>