I tried to make strcpy
myself. It should work, I even copied and pasted the (almost exact code) from someones post here about strcpy
. Both give me a "Segmentation Fault".
char* strcpy(char * destination, const char * source)
{
while( (*destination++ = *source++) != '\0' )
;
return destination;
}
What's wrong with this code?
char* a = "hello";
cout << strcpy(a, "Haha") << endl;