return char array function error
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2514539/is-it-a-good-idea-to-return-const-char-from-a-function">Is it a good idea to return &ldquo; const char * &rdquo; from a function?</a><br>
  <a href="http://stackoverflow.com/questions/7769998/how-to-return-char-array-in-c">how to return char array in c++?</a>  </p>
</blockquote>



<p>What is wrong with this return? I'm trying to return the current path using the following function but it doesn't seems to be correct: </p>

<p>Please Not: I need an char return not string.</p>

<pre><code>char* getINIfile(void)
{
    char buffer[MAX_PATH];
    GetModuleFileName( NULL, buffer, MAX_PATH );
    string::size_type pos = string( buffer ).find_last_of( "\\/" );
    string path = string( buffer ).substr( 0, pos) + "\\setup.ini";

    char *ini_local= (char*)path.c_str();

    printf(ini_local); // so far output OK!

    return ini_local;
}

main
{
    printf(getINIfile()); // output Not OK! 

    char mybuffer[200];
    GetPrivateProfileStringA( "files","DLL","0",  mybuffer,200, getINIfile());
    printf(mybuffer);

}
</code></pre>
