I have an application where I have a function that I want to return some data from a file and the data retrieved from the file can be different so the memory size of the variable has to be dynamic.
What I have is a function like
// where I do something like
// read file and fill an std:string object up
While not end of file
strBuff.append(line from file);
// here I create new memory and pass it back from to the caller
*buff = new char[strBuff.length()];
When I call the function it is something like:
char *buffOut = NULL;
But I get an error if I try something like:
delete  buffOut;
What is the correct way to delete this memory I have allocated in the GetData function?