What is the simplest way to convert char[] to/from tchar[] in C/C++(ms)?

后端 未结 8 1009
遥遥无期
遥遥无期 2020-12-03 17:02

This seems like a pretty softball question, but I always have a hard time looking up this function because there seem there are so many variations regarding the referencing

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-03 17:47

    Although in this particular situation I think the TChar is a wide character I'll only need to do the conversion if it isn't. which I gotta check somehow.

    if (sizeof(TCHAR) != sizeof(wchar_t))
    {  .... }
    

    The cool thing about that is both sizes of the equals are constants, which means that the compiler will handle (and remove) the if(), and if they are equal, remove everything inside the braces

提交回复
热议问题