pengwn 21 Newbie Poster

The code below gives :
Data is : hello srikanth its me
Data is :
Data is :
Data is :

#include <string>
#include <iostream>
#include <boost/regex.hpp>

boost::regex e("(\\w)\\s*(\\w)\\s*(\\w)");
boost::match_results<std::string::const_iterator> what;


int main()
{
   int i;
   const std::string input = "hello srikanth its me";
   boost::regex_match(input, what, e, boost::match_default | boost::match_partial);

   for ( i = 0; i < 4; ++i )
      std::cout << " Data is : " <<  what[i].str() << std::endl;
}

how do i make it to print:
Data is : hello
Data is : srikanth
Data is : its
Data is : me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.