Hi
This whole pointer thing is getting the better of me.
first i have a call to method "convertToCString" in my main:
int value = 21;
char* cstr = NULL
convertToCString(value, &cstr);
printf("\"%s\"\n". &cstr);
cstr = NULL
delete cstr;
the method looks like this
bool convertToCString(int& refConstInt, char** ptrtoCharPtr)
{
ptrToCharPtr = new char*;
if (sprintf(*ptrtoCharPtr, "%d", refConstint) > 0)
return true;
else
return false;
}
I get a segmentation error in the output.
but when i do this:
bool convertToCString(int& refConstInt, char** ptrtoCharPtr)
{
ptrToCharPtr = new char*;
char* blah
if (sprintf(blah, "%d", refConstint) > 0)
return true;
else
return false;
}
It output the correct value ? How does this work ? I can't make any sense of it.