Here I try to concatenate three character strings using wcsncat()
.
clang_string
AAAAAAAAAA
dlang_string
BBBBBBBBBBB
winpointer_to_string
CCCCCCCCCC
import std.stdio;
@system void main(){
import std.utf : toUTF16z, toUTF16;
import core.stdc.wchar_ : wcsncat, wcslen, wprintf;
import core.stdc.stdlib : wchar_t;
import core.sys.windows.winnt : LPCWSTR;
wchar_t* clang_string = cast(wchar_t *)"AAAAAAAAAA";
string dlang_string = "BBBBBBBBBBB";
LPCWSTR winpointer_to_string = "CCCCCCCCCC";
wcsncat(clang_string, dlang_string.toUTF16z, wcslen(dlang_string.toUTF16z));
// String output: AAAAAAAAAABBBBBBBBBBB
wcsncat(clang_string, winpointer_to_string, wcslen(winpointer_to_string));
// String output: AAAAAAAAAABBBBBBBBBBBBBBBBBBBB
// Expected string: AAAAAAAAAABBBBBBBBBBBCCCCCCCCCC
wprintf(clang_string);
// String output: AAAAAAAAAABBBBBBBBBBBBBBBBBBBB
// Expected string: AAAAAAAAAABBBBBBBBBBBCCCCCCCCCC
}
Problem:
Any following concatenated string after "wcsncat()
concatenation of dlang_string.toUTF16z
string", happen to not be printed and gets overwritten.
The Expected output:
I was expecting the wprintf()
result to be AAAAAAAAAABBBBBBBBBBBCCCCCCCCCC
The wprintf()
result I've received is this: AAAAAAAAAABBBBBBBBBBBBBBBBBBBB