so the method works fine but I'm trying to create a void function of the above code which would have 2 arguments 1 a string like "Hi", which would then be placed inside AN ARBITRARY memory buffer like if you have a char array like char ary[3]; You could pass this to the function like
StrToAry("Hi", ary);
and that would then place Hi into your ary.
The above code doesn't work though any ideas on if this is possible and how would you do it it's confusing?
Memory wouldn't be left hanging since it's deleted on the fly as soon as the function is over right but with that data you can permanently copy it into ANOTHER array of memory is this ok?
No.
It should have been delete[], but things below the return will never execute, as you already returned.
I don't understand what you want. You do know about std::string ¿so why go back to char* ?
Memory wouldn't be left hanging since it's deleted on the fly as soon as the function is over right but with that data you can permanently copy it into ANOTHER array of memory is this ok?
Memory is never freed here. What happens on line 11? So do you ever reach line 12?
Regarding the original code:
Don't allocate memory in the function. Simply copy it over to the buffer supplied. This isn't very safe of course, since the function doesn't know how large the buffer is. Or, just use std::strcpy instead of defining your function since you're basically trying to reimplement that functionality.