VC + + Common data type conversion

Source: Internet
Author: User

char* conversion into LPCTSTR

    Const Char* dibfilename;     int num = MultiByteToWideChar (00, Dibfilename,-10);     New Wchar_t[num];    MultiByteToWideChar (00, Dibfilename,-1, wide, num);

    Char m_filename[];     // this is possible in multibyte or Unicode mode.      _bstr_t bstrtmp (m_filename);     = (LPTSTR) bstrtmp;

parsing:

Num Gets the space required for long bytes
MultiByteToWideChar () means that the characters in s are passed to the memory that the PS points to. 1 indicates the transfer to ' + ' in S, Num represents the number of bytes passed.

char* conversion into CString

    // char *-->cstring     // Outputfilepath = "G:\\testdll"    Const Char* Outputfilepath;    CString str1 (outputfilepath);

CString conversion into char*

Char*Cdib::cstringtochararray (CString str) {Char*ptr; #ifdef _unicode LONG Len; Len= WideCharToMultiByte (CP_ACP,0, str,-1Null0, NULL, NULL); PTR=New Char[Len +1]; Memset (PTR,0, Len +1); WideCharToMultiByte (CP_ACP,0, str,-1, PTR, Len +1, NULL, NULL);#elseptr=New Char[Str. Getalloclength () +1]; sprintf (PTR, _t ("%s"), str);#endif    returnptr;}

VC + + Common data type conversion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.