It shouldn't be a general problem, the following program runs fine.
Make sure the pointer you receive contains what you want it to
hold. Using assertions like above is a good method for verifying that.
PHP Code:
#include <string.h>
#include <string>
#include <iostream>
using namespace std;
string test( const char* tocopy )
{
string s = tocopy;
if( strcmp( s.c_str(), tocopy ) != 0 )
{
cout << s;
}
return s;
}
int main()
{
char szBuffer[1000];
memset( szBuffer, 0, 999 );
memset( szBuffer, 'A', 900 );
char* pc = szBuffer;
string str = test( pc );
if( strcmp( str.c_str(), pc ) != 0 )
{
cout << str;
}
cout << endl << "the end. no errors.";
return 0;
}