C ++ implementation of the approach
#include <bits/stdc++.h> NEW_LINE using namespace std ; template < size_t N > void splitString ( string ( & arr ) [ N ] , string str ) { int n = 0 ; istringstream iss ( str ) ; for ( auto it = istream_iterator < string > ( iss ) ; it != istream_iterator < string > ( ) && n < N ; ++ it , ++ n ) arr [ n ] = * it ; } inline bool ends_with ( std :: string const & value , std :: string const & ending ) { if ( ending . size ( ) > value . size ( ) ) return false ; return std :: equal ( ending . rbegin ( ) , ending . rend ( ) , value . rbegin ( ) ) ; }