C++ error: cannot convert ‘std::basic_string<char>’ to ‘const char*’
<p>I'm using a function to download a file.</p>

<pre><code>void downloadFile(const char* url, const char* fname) {
  //..
}
</code></pre>

<p>This is called like :</p>

<pre><code>downloadFile("http://servera.com/file.txt", "/user/tmp/file.txt");
</code></pre>

<p>This working fine.  </p>

<p>But I want to change the URL to be a value from an array. The array stores encrypted values which when decrypted are strings, so I get the issue <code>error: cannot convert ‘std::basic_string&lt;char&gt;’ to ‘const char*’</code></p>

<p>I've tried:</p>

<pre><code> string test = decode(foo[5]);
 const char* t1= test.c_str();
 downloadFile(t1 "filename.txt", "/user/tmp/file.txt");

downloadFile(t1 + "filename.txt", "/user/tmp/file.txt");
</code></pre>

<p>and </p>

<pre><code>downloadFile((decode(foo[5]).c_str()) + "filename.txt", "/user/tmp/file.txt");
</code></pre>

<p>which gives:
<code>error: invalid operands of types ‘const char*’ and ‘const char [17]’ to binary ‘operator+’</code></p>

<p>What am I doing wrong ?</p>

<p>Thanks</p>