Itβs good that the previous question was answered, but I found another problem.
What to do, if:
char *test(int ran){ char *ret = new char[ran];
And then run it:
for(int i = 0; i < 100000000; i++){ string str = test(rand()%10000000+10000000); // process... // no need to delete str anymore? string destructor does it for me here? }
So, after converting a char * string to a string, I no longer need to worry about deleting?
Edit: As I said, I have to delete[] call each new[] , but in my case this is not possible since the pointer is lost, so the question is: how to convert char to the correct string?
c ++ string new-operator char delete-operator
Newbie
source share