C++ Wiki

2015.10.15

Tags: STL

std::stringstreamの使い方

サンプルコード

#include <iostream>
#include <sstream>

int main()
{
  std::string string = "abc defg hi j";
  std::stringstream stream(string);

  while(!stream.eof()){
    std::string s;
    stream >> s;
    std::cout << s << std::endl;;
  }

  return 0;
}

実行結果

abc
defg
hi
j