So i convert lets say its a std::string to char *
anyway debugger claims its there, but whenever i try to get value from char* it says its null and i get access violation 000000
i think its because of * in a void parameter anyway heres a code:
typedef std::string AnsiString;
void main()
{
int p;
char * u = 0;
AnsiString pk = "R";
CopyToPCHAR(pk, &p, u);
ShowMessage(AnsiString(u,p)); //error
}
template <class type> void DeleteIfPersist(int * len, type * p)
{
if (p != 0) delete [] p;
p = 0;
(*len) = 0;
}
inline void CopyToPCHAR(AnsiString str, int * len, char * p /* i think heres a problem */)
{
DeleteIfPersist(len, p);
(*len) = str.Length();
if ((*len) > 0)
{
p = new char[ (*len) ];
strcpy(p, str.c_str());
}
}
so what is going on?