Programming has been a headache recently. This type of conversion can be done by knowing that it can be switched, but it is always hard to remember. I will keep searching through the Internet and summarize it here. For future convenience, of course,
Original article address:Convert: char *,
Char []
, Cstring,
String Conversion
Author:Gisldq
(1) OverviewString and cstring are both string template classes. string is a string class defined by the standard template class (STL) and has been
Unicode (unified code, universal code, Single Code) is a character encoding used on a computer. It sets a unified and unique binary code for each character in each language to meet the requirements of cross-language and cross-platform text
Conversion between string, CString, char *
Int to CString:CString. Format ("% d", int );...............................String to CStringCString. format ("% s", string. c_str ());C_str () is indeed better than data.....................................
turn: char*, char[], CString, string conversion (i) OverviewString and CString are string template classes, string classes defined by the Standard template class (STL), are included in the C + + standard;CString (typedef CStringT > CString) is the
Recently, the conversion of cstring, tchar *, and char * is used.
Find a detailed article. Reference it for your convenience.
Char is type. tchar is also! However, he can determine whether it is Char or w_char by defining a unicode macro;
The transformation between string,cstring,char*
int Turn CString:Cstring.format ("%d", int);...............................String Turn CStringCstring.format ("%s", String.c_str ());Using C_str () is indeed better than data ()........................
About wchar_t
In the C ++ standard, wchar_t is a wide character type. Each wchar_t type occupies 2 bytes and has a 16-bit width. Wchar_t is required for the representation of Chinese characters. Char, we all know, occupies a byte, 8-bit width.
Cstring, Int, String, char * ConversionString to cstringCstring. Format ("% s", String. c_str ());Convert Char to cstringCstring. Format ("% s", char *);Char to stringString S (char *);String to char *Char * P = string. c_str ();Cstring to
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.