-2

I have a string like this:

17, the day is beautiful , day

. And I want to split this string in the first ','. For example I want to take 2 strings. one for 17 and two for the day is beautiful , day

Roka
  • 17
  • 1
  • 7
  • The [`std::getline`](http://en.cppreference.com/w/cpp/string/basic_string/getline) function can actually use any arbitrary character as "line ending", not only newline. It can be used together with [`std::istringstream`](http://en.cppreference.com/w/cpp/io/basic_istringstream) for such string "splitting". – Some programmer dude Oct 13 '17 at 09:17
  • Since you're looking for first of something `string::find_first_of` is a good match ;) – pergy Oct 13 '17 at 09:41

1 Answers1

0
#include <boost/algorithm/string.hpp>
std::vector<std::string> strs;
boost::split(strs, "17, 132, asdasd, 111", boost::is_any_of(","));
Ivan Sheihets
  • 802
  • 8
  • 17
  • I have for example two ',' but I want to split only for first. In your example I want to take 2 elements in vector 17 and 132, asdasd, 111 – Roka Oct 13 '17 at 10:05