Skip to content

Instantly share code, notes, and snippets.

@yurial
Created March 25, 2013 15:00
Show Gist options
  • Save yurial/5237722 to your computer and use it in GitHub Desktop.
Save yurial/5237722 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <stdio.h>
#include <iterator>
#include <iostream>
#include "../ext/strtok.h"
using ext::strtok;
using ext::uniqtok;
int test0(const char* delim, const char* str)
{
typename strtok<>::container_t result = strtok<>( delim, str );
std::cout << result.size() << " elements found: ";
std::ostream_iterator<std::string> out( std::cout, " " );
std::copy( result.begin(), result.end(), out );
std::cout << std::endl;
return EXIT_SUCCESS;
}
int test1(const char* delim, const char* str)
{
typename uniqtok<>::container_t result = uniqtok<>( delim, str );
std::cout << result.size() << " uniques elements found: ";
std::ostream_iterator<std::string> out( std::cout, " " );
std::copy( result.begin(), result.end(), out );
std::cout << std::endl;
return EXIT_SUCCESS;
}
int main(int argc, char* argv[])
{
if ( 3 != argc )
{
fprintf( stderr, "usage: %s <delimeter> <string>\n", argv[0] );
return EXIT_FAILURE;
}
return test0( argv[1], argv[2] ) || test1( argv[1], argv[2] );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment