MFC cstring to int, double, tchar * type

Source: Internet
Author: User

Convert MFC cstring to int, double, and Char Types

// Convert cstring to int <br/> cstring szport = l "2589"; <br/> int nport = _ ttoi (szport ); </P> <p> // convert cstring to double <br/> cstring szport = l "2589.00"; <br/> double nport = _ ttol (szport ); </P> <p> // convert other types to cstring <br/> int nport = 2589; <br/> char IP [32] = "this way "; <br/> cstring STR; Str. empty (); <br/> Str. format (_ T ("% d: % s"), nport, ip ); </P> <p> // convert cstring to tchar * <br/> cstring CSTR (L "hello"); <br/> tchar * pstr = CSTR. getbuffer (STR );

 

Char and wchar_t

/* -------------------------------------- <Br/> file: Mr. h <br/> using macros to define the same function name can avoid modifying the compiler compiling environment <br/> --------------------------------------- */<br/> # pragma once </P> <p> # ifndef mr_h <br/> # define mr_h </P> <p> # ifdef Unicode <br/> # DEFINE _ mrstrncpy wcsncpy <br/> # DEFINE _ mrstrcpy wcscpy <br/> # define _ mrstrlen wcslen <br/> # DEFINE _ mrstrcat wcscat <br/> # DEFINE _ mrstrcmp wcscmp <br/> # else <br/> # DEFINE _ mrstrncpy strncpy <br/> # DEFINE _ mrstrcpy strcpy <br/> # DEFINE _ mrstrlen strlen <br/> # DEFINE _ mrstrcat strcat <br/> # DEFINE _ mrstrcmp strcmp <br/> # endif </P> <p> # endif

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.