STD: String operations

Source: Internet
Author: User

Convert the lpctstr to STD: String

 
Lpctstr folder_path; char STR [1024]; wsprintfa (STR, "% s", folder_path); string STR _ (STR );

Remove the string space:

 
# Include <iostream> # include <string> # include <boost/algorithm/string. HPP> using namespace STD; using namespace boost; int main () {string S = "Hello boost !! "; Trim (s); cout <S <Endl ;}

Conversion between string and wstring:

#include 
  
    # include 
   
     // prototype for conversion functionsstd: wstring stringtowstring (const STD :: string & S); STD: String wstringtostring (const STD: wstring & S); STD: wstring stringtowstring (const STD: string & S) {STD :: wstring temp (S. length (), l''); STD: Copy (S. begin (), S. end (), temp. begin (); Return temp;} STD: String wstringtostring (const STD: wstring & S) {STD: String temp (S. length (), ''); STD: Copy (S. begin (), S. end (), temp. begin (); Return temp;} using namespace STD; int main () {string S1 = "hello"; wstring S2 = stringtowstring (S1); S1 = wstringtostring (S2 ); return 0 ;}
   
  

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.