Hi,
I am doing an exercise that states to write a function that copies a c-style string into memory it allocates on the free store and to not use any standard library functions. This is what I have so far:
It seems to work, and the cout prints correctly. My concern is that I have allocated memory on the free store without immediate initialisation, that was done in the line below. Is this how it is done?Code:char* foo(char* c) { char* e = new char; e=c; return e; } int main() { char* f = func("hello"); cout << f; }
Thanks,



LinkBack URL
About LinkBacks



