How do I do this thing.
char* ToString(int num) {
char* str = new char[len(num)];
//conversion
return str;
}
And by calling this.
string someStr = ToString(someInt);
Should I free the someStr
here?
I know I always need to delete
whenever I use new
.
And what if I call this function multiple times, do I allocate memory and just leaving them behind not using it?