はきだめC/C++下級者の質問箱 2 at TECH
[2ch|▼Menu]
11:デフォルトの名無しさん
06/08/25 23:22:57
>>6
/**
文字列を指定の文字で分割し、単語のリストを作ります
@param text 入力文字列(","や";"を含む文字列)
@param separators 分裂文字列(",.;:","\n")
@param words 出力文字列リスト
*/
bool split(const string& text,
  const string& separators,
  vector<string>& words)
{
  int n = text.length();
  int start = text.find_first_not_of(separators);

  while ((start >= 0) && (start < n))
  {
     int stop = text.find_first_of(separators, start);
     if ((stop < 0) || (stop > n)) stop = n;
     words.push_back (text.substr(start, stop-start));
     start = text.find_first_not_of(separators, stop+1);
  }
  return true;
}


次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

4865日前に更新/249 KB
担当:undef