I'm continuing my project and found a strange error, I can think of ten thousand hacks to get around it and a few ways to fix it properly, but my curiousity is peeked. why Is AStringBufEx end result 18 characters long when the Lenth of the initial string is only 13?
Runtime:
oString = 0x0012fb7c " data/level1/"
Lenth = 13
AStringBufEx = 0x003979f0 " data/level1/﷽﷽ꮫꮫꮫꮫﻮ"

void DrawDebugText(wchar_t oString[100])
{
	int Lenth = wcslen(oString);
	wchar_t* AStringBufEx;
	AStringBufEx = new wchar_t[Lenth];
	*AStringBufEx = NULL;
	for(int i=0;i<Lenth;i++)
	{
	AStringBufEx[i]=oString[i];
	}
}

line 6 is unnecessary.

you are not null-terminating the destination string. wcslen() returns the number of characters in the string and does not include the null terminator. So add a line after line 10 to null terminate the destination string.

You could also have just used wcscpy() and not bother with all the hassle of rolling your own copy function.

Comments
great understand of the problem and solution

line 6 is unnecessary.

you are not null-terminating the destination string. wcslen() returns the number of characters in the string and does not include the null terminator. So add a line after line 10 to null terminate the destination string.

You could also have just used wcscpy() and not bother with all the hassle of rolling your own copy function.

I see, so the array isn't actually longer than Lenth, it's just being read past Lenth as there is no null terminator. Thank you very much Ancient Dragon It makes scene now.

As for wcscpy I have a strange habit of trying to handle everything I possibly can in my code myself, thus why despite the existence of many-a-2D library I've created my own DX9 wrapper.

Do you also manufacture your own automobile? Grow your own food? Milk your own cow? Build your own house? You didn't write wcslen() so why be so inconsistent. When you write all that yourself you just have lots more code that introduces bugs you have to fix, like this one.

Comments
Excellent!
'Milk your own cow' - don't EVER call her that, she'll slap you.
This question has already been answered. Start a new discussion instead.