I thought to find unique elements from a string data is straightforward. But it turned out to be not!
The "unique" function definitely works well on vector<int>. But when I tried it on vector<char>, it seems it does not. I tested by "distance" between the beginning of the output vector and the iterator,it, returned from the unique function. The outputSize is still 8 as same as the input string "abacacde".
Why? Please help.
Thanks,
L
Below is my current output and code.
----------------------Output:
inputStr.begin()a
inputStr.end()e
*(it-1)=e
outputSize=8
---------------------Code:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
using namespace std;
void stringFilter(const char *pInputStr, long lInputLen, char *pOutputStr)
{