title: warning: deprecated conversion from string constant to 'char*'
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1524356/c-deprecated-conversion-from-string-constant-to-char">C++ deprecated conversion from string constant to ‘char*’</a>  </p>
  </blockquote>
  
  
  
  <p>I was looking into strings in C++ and tried an exercise to experiment the behaviour of some of the functions defined in the string library. I compiled the same program yesterday and everything worked with absolutely no warnings or errors. However, today I tried to compile the program again, but I received the following warning. </p>
  
  <pre><code>D:\C++ CodeBlocks Ex\Strings\main.cpp||In function 'int main()':|
  D:\C++ CodeBlocks Ex\Strings\main.cpp|11|warning: deprecated conversion from string constant to 'char*'|
  ||=== Build finished: 0 errors, 1 warnings ===|
  </code></pre>
  
  <p>the warning referes to this line <code>strncat("Hello",string,STRMAX-strlen(string));</code>. I am not sure but from what I suspect is that the strncat function does not like the ideaa of having to concatenate an array of literals with a string constant. Any help on this will be much appreciated.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string.h&gt;
  
  using namespace std;
  
  int main(){
      #define STRMAX 599
      char string[STRMAX+1];
      cout&lt;&lt;"Enter name: ";
      cin.getline(string,STRMAX);
      strncat("Hello",string,STRMAX-strlen(string));
      cout&lt;&lt;string;
      return 0;
  }
  </code></pre>