zoukankan      html  css  js  c++  java
  • CString——Left、Right、Find、ReverseFind

    CString——Left、Right、Find、ReverseFind

    http://hi.baidu.com/shawmar/item/08b30afb0f32d46f3c1485ec

    CString——Left、Right、Find、ReverseFind

    CString::Left(intnCount)

    ——返回字符串前nCount个字符的字符串

    example:

      CString str(_T("Shop,车间"));

      str = str.Left(4);

    结果:str="Shop";

    CString::Right(int nCount)

    ——返回字符串后nCount个字符的字符串

    example:

      CString str(_T("Shop,车间"));

      str = str.Right(2);

    结果:str="车间";

    CString::Find(_T(","))

    返回“,”在字符串中的索引值

    example:

     CString str(_T("Shop,车间"));

      int idex = str.Find(_T(","));

    此时:idex=4;

    宗:要想获得“,”右側内容

    str = str.Right(str.GetLength()-1-str.Find(_T(",")));

    当中:

    str.GetLength()=7;

    -1排除“,”

    -str.Find(_T(","))排除“,”前的全部字

    CString::ReverseFind

      int ReverseFind( TCHAR ch ) const;

      返回值:

      返回此CString对象中与要求的字符匹配的最后一个字符的索引;假设没有找到须要的字符则返回-1。

      參数: ch 要搜索的字符。

      说明:

      此成员函数在此CString对象中搜索与一个子串匹配的最后一个字符。此函数类似于执行时函数strrchr。

      演示样例:// CString::ReverseFind演示样例:

      CString s( "abcabc" );

      ASSERT( s.ReverseFind( 'b' ) == 4 );

  • 相关阅读:
    Spring Cloud概述
    Servlet调用流程和Spring MVC调用流程
    待看文章链接
    MyBatis之 resultMap 元素子元素详解
    MyBatis核心配置文件模板代码
    ios上架
    iOS打包部署
    Android XML绘图(4)——Bitmap
    Android XML绘图(2)——Layer
    Android XML绘图(3)——Selector
  • 原文地址:https://www.cnblogs.com/hrhguanli/p/3957310.html
Copyright © 2011-2022 走看看