zoukankan      html  css  js  c++  java
  • Cstring使用说明

    • CString::Left(intnCount)const; //从左边1开始获取前 nCount个字符
    • CString::Mid(intnFirst)const; //从左边第 nCount+1个字符开始,获取后面所有的字符
    • CString::Mid(intnFirst,intnCount)const; //从左边第 nFirst+1 个字符开始,获取后面nCount个字符
    • CString::Right(intnCount)const; //从右边1开始获取从右向左前 nCount个字符

    注:
    在函数后面加 const 的意思是:
    如果一个类声明了一个常量对象,这个对象只能使用后边带 const 这个的方法.

    例:

    CString a,b;
    a = "123456789";
    
    b =a.Left(4); //值为:1234
    b =a.Mid(3); //值为:456789
    b = a.Mid(2, 4); //值为:3456
    b = a.Right(4); //值为:6789

    在一个较大的字符串中查找字符或子字符串

    • int Find( TCHAR ch ) const; (类似的还有ReverseFind,查看区别)
    • int Find( LPCTSTR lpszSub ) const;
    • int Find( TCHAR ch, int nStart ) const;
    • int Find( LPCTSTR pstr, int nStart ) const;

    返回值:
    返回此CString对象中与需要的子字符串或字符匹配的第一个字符的从零开始的索引;如果没有找到子字符串或字符则返回-1。

    参数:
    ch要搜索的单个字符。
    lpszSub要搜索的子字符串。
    nStart字符串中开始搜索的字符的索引,如果是0,则是从头开始搜索。如果nStart不是0,则位于nStart之前的字符不包括在搜索之内。
    pstr指向要搜索的字符串的指针

    例:

    CString::Find( TCHAR ch )
    CString s( "abcdef" );
    int n = s.Find( 'c' ); // 结果 n = 2
    int f = s.Find( "de" ) ;// 结果 f = 3
  • 相关阅读:
    Spark开发-SparkUDAF(二)
    Spark开发-Spark UDAF(一)
    Spark开发-Spark中类型安全UDAF开发示例
    Spark开发_构建TypeSafe的Dataset
    布隆过滤器(Bloom Filter)
    一个 Spark 应用程序的完整执行流程
    Spark的RPC
    Spark调优
    Hbase系列文章
    Flink怎么做到精确一次的?
  • 原文地址:https://www.cnblogs.com/acmwangpeng/p/5524912.html
Copyright © 2011-2022 走看看