// stringstream を使ってみます // 文字列中の whitespace を全て削除したい時は楽です #include <iostream> #include <string> #include <sstream> using namespace std; int main() { stringstream ss; ss << " :aaa bbb / ccc , aaa , bbb \t d \n ddd:"; string sz_string,sz_one; while ( ss >> sz_one ) { sz_string += sz_one; } cout << "|" << sz_string << "|" << endl; return 0; } // // >> は ストリーム中の文字列を whitespace で区切って // 順次トークンを渡してくれます //