title: pointer to char array C++
body: <p>I have problem converting next code from c to c++:<br>
  I have a function that takes an array of move sequences (sequence of chars from a to i) as arg.</p>
  
  <p>code:</p>
  
  <pre><code>void mkmove(char** move) {
      int i = 0;
      char* p = NULL;
      int moves[9][9];
  
      for(int i = 0; i &lt; 9; i++) {
          for(p = move[i]; *p; p++) {
              moves[i][*p - 'a'] = 3;
          }
      }
  }
  
  int main() {
      char* movestr[] = {"abde", "abc", "bcef", "adg", "bdefh", "cfi", "degh", "ghi", "efhi"};
      mkmove(movestr);
  
      return(0);
  }
  </code></pre>
  
  <p>gcc compiles that code fine, but if I try to compile it with g++ it gives me next warning:<br>
  main.cpp:17:39: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]</p>
  
  <p>I believe this warning comes from the fact that string in C is defined as char[], while c++ uses std::string.<br>
  So I tried replacing the code to use C++ strings like this:</p>
  
  <pre><code>void mkmove(std::string* move) {
  </code></pre>
  
  <p>in mkmove function defenition, and:</p>
  
  <pre><code>std::string* movestr = {'abde', "abc", "bcef", "adg", "bdefh", "cfi", "degh", "ghi", "efhi"};
  </code></pre>
  
  <p>in main function and add the C++ string header file:</p>
  
  <pre><code>#include &lt;string&gt;
  </code></pre>
  
  <p>but now I get errors:<br>
  main.cpp: In function ‘void mkmove(std::string*)’:<br>
  main.cpp:11:21: error: cannot convert ‘std::string {aka std::basic_string}’ to ‘char*’ in assignment<br>
  main.cpp: In function ‘int main()’:<br>
  main.cpp:19:39: error: scalar object ‘movestr’ requires one element in initializer  </p>
  
  <p>I also tried some other tweaks but that gave me least errors on compile.</p>
  
  <p>So what is proper way to convert top code from C to C++?</p>
  
  <p>Thanks for answers!</p>
  
  <p>-Slovenia1337</p>