Type conversion and corresponding string operation functions in C ++

Source: Internet
Author: User

1. Convert int, double to cstring:
Cstring STR;
Int;
Double B;
Str. Format ("% d % F", a, B );

2. Conversion from char * To cstring:
Char * s = "this is a string ";
Cstring STR = _ T (s );

3. Conversion from cstring to char:
Cstring STR = _ T ("Chinese character is also OK. ");
// Const char * s = (lpctstr) STR;
Char * s = Str. getbuffer ();
Str. releasebuffer ();
S = 0;

4. Const char * to int, double
Int I = atoi ("100 ");
Double I = atof ("100.0 ");

The cstring can be connected to the char * string by the plus sign.
Append (_ T ("APPEND string "));
Use Find (_ T ("query string, return int type "));
Insert (INT index, _ T ("insert string "));
Returns the string length with getlength;
Uses right (INT size) to extract the string with the tail length.
Use left (INT size) to intercept the header length string
Use Right, left, and find to intercept strings at specific positions.

 

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/sworderandy/archive/2007/12/26/1968181.aspx

Related Article

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.