为了从一字串里分段提取子串,常用strtok函数。
请问,诸位还有使用其他方法吗?

解决方案 »

  1.   

    CString::Find//typedef CStringT< TCHAR, StrTraitATL< TCHAR > > CAtlString;CAtlString s( "abcdef" );
    _ASSERT( s.Find( 'c' ) == 2 );
    _ASSERT( s.Find( "de" ) == 3 );CAtlString str("The waves are still");
    int n = str.Find('e', 5);
    _ASSERT(n == 7);
      

  2.   

    boost::tokenizer
    #include<boost/tokenizer.hpp>
    void path_to_components_que(LPCTSTR cur_dir_buf,std::deque<tchar_string>& qque)
    {
    typedef boost::tokenizer<boost::char_separator<TCHAR>,tchar_string::const_iterator,tchar_string > tokenizer;
    boost::char_separator<TCHAR> sep( _T("\\"));
    tchar_string str = cur_dir_buf;
    tokenizer tokens(str, sep);
    tokenizer::iterator tok_iter = tokens.begin();
    tchar_string group_element;
    while(tok_iter!=tokens.end())
    {
    group_element = *tok_iter;
    qque.push_back(group_element);
    tok_iter++;
    }
    if(!PathIsDirectory(cur_dir_buf) && qque.size()>1)
    {
    qque.pop_back();
    }
    }
      

  3.   

    要这么多方法干嘛,看楼上的星星们mfc,atl,stl全部都出来了哈