Converting string to tchar in VC++

前端 未结 2 1904
礼貌的吻别
礼貌的吻别 2020-12-11 22:52

how I can convert string to tchar in VC++?

string internetprotocol=\"127.4.5.6\";

 TCHAR szProxyAddr[16]; 

i want to

相关标签:
2条回答
  • 2020-12-11 23:05
    #include <atlstr.h>
    
    
    string internetprotocol="127.4.5.6";
    TCHAR szProxyAddr[16]; 
    
    _tcscpy_s(szProxyAddr, CA2T(internetprotocol.c_str()));
    

    _tcscpy_s is generic strcpy version which works both in Unicode and Multi-Character configurations. CA2T converts const char* to TCHAR*, according to szProxyAddr variable type.

    Be careful with destination variable length.

    0 讨论(0)
  • 2020-12-11 23:19

    You may try like this:

    #include <atlstr.h>
    _tcscpy_s(szProxyAddr, CA2T(internetprotocol.c_str()));
    
    0 讨论(0)
提交回复
热议问题