zoukankan      html  css  js  c++  java
  • C++标准库开发心得

    最近放弃MFC,改用C++标准库开发产品。毕竟MFC用熟了,马上改用STL还不太习惯。下面列出下总结的改用STL遇到的问题和解决办法:

    1.清除空格

    remove_if(iterBegin, iterEnd, isspace) 会遍历字符串,将空格之后的字符依次往前拷贝,

    之后iter为“of MFC.”,为多余字符串的位置,字符个数为空格的个数。需要使用erase将iter部分清除。清除之后字符串为“IuseSTLtodevelopinsteadofMFC.”

    #include <string>
    #include <algorithm>

    using namespace std;

    int _tmain(int argc, _TCHAR* argv[])
    {
        std::string str = "I use STL to develop instead of MFC.";
        std::string::iterator iterBegin = str.begin();
        std::string::iterator iterEnd = str.end();
        std::string::iterator iter = remove_if(iterBegin, iterEnd, isspace);
        str.erase(iter, str.end());
        return 0;
    }

  • 相关阅读:
    mysql的sql性能分析器
    Maven(一)
    SVN使用(二)
    SVN使用(一)
    php smarty section使用
    php smarty foreach循环注意
    PHP unlink() 函数
    PHP file_exists() 函数
    PHP realpath() 函数
    PHP dirname() 函数
  • 原文地址:https://www.cnblogs.com/ityujian/p/3428116.html
Copyright © 2011-2022 走看看