News:

GinGly.com - Used by 85,000 Members - SMS Backed up 7,35,000 - Contacts Stored  28,850 !!

Main Menu

Use unique_copy to copy elements in an array to list with back_inserter

Started by aruljothi, Jun 11, 2009, 07:44 PM

Previous topic - Next topic

aruljothi


#include <iostream>
#include <list>
#include <algorithm>
#include <string>

using namespace std;

int main( ) {
   string arrStr[5] = {"A", "B", "A", "D", "E"};

   list<string> lstStrDest;
   unique_copy(&arrStr[0], &arrStr[5], back_inserter(lstStrDest));

   for (list<string>::iterator p = lstStrDest.begin( );
        p != lstStrDest.end( ); ++p) {
      cout << *p << endl;
   }
}