error: invalid conversion from ‘const char*’ to ‘char*’
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/289347/using-strtok-with-a-stdstring">Using strtok with a std::string</a>  </p>
</blockquote>



<pre><code>#include&lt;iostream&gt;
#include &lt;string&gt;
#include &lt;string.h&gt;

using namespace std;

int main()
{
    string s("hello hi here whola");
    string background;
    char *strval;

    char* tok = strtok_r(s.c_str()," ",&amp;strval);
    while(tok !=NULL)
    {
    cout &lt;&lt; tok &lt;&lt;"\n";
    if (tok == "&amp;")
        background = tok;
    else
    {
        statements1;
        statement2.. ;
    }
    tok = strtok_r(NULL, " ",&amp;strval);
    }

    return 0;
}
</code></pre>

<p>output:</p>

<pre><code>new.cpp: In function ‘int main()’:
new.cpp:13:47: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
/usr/include/string.h:359:14: error:   initializing argument 1 of ‘char* strtok_r(char*, const char*, char**)’ [-fpermissive]
</code></pre>
