I am trying to get wchar_t* in int format as a parameter. I walked a lot, but I was only more embarrassed. So, consider this code:
int main(int argc, char** argv) { wchar_t buf[16]; wsprintf(buf, L"%d", 5); wprintf(L"[%ls]\n", buf); system("pause"); return 0; };
Assuming wchar_t , wsprintf and wprintf are broad equivalents of char , sprintf and printf respectively, I expected the above to print [5] , but it prints garbage between [ and ] . What is the right way to achieve the desired result? And what am I misunderstanding here?
(I must clarify that portability is more important than security here, so I would like to know a solution that uses this family of functions instead of the more secure extensions associated with the manufacturers.)
source share