Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting string to tchar in VC++

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

string internetprotocol="127.4.5.6";

 TCHAR szProxyAddr[16]; 

i want to set:

szProxyAddr=internetprotocol;

how i can do it?

like image 663
User123422 Avatar asked Mar 30 '26 23:03

User123422


1 Answers

#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.

like image 175
Alex F Avatar answered Apr 02 '26 14:04

Alex F



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!