I am trying to reverse a std::string
:
void reverseString(vector<char>& s)
{
auto i = s.begin();
auto j = s.rbegin();
while (i != j)
{
char tmp = *i;
*i = *j;
*j = tmp;
i++;
j--;
}
}
However, this happened when I tried to compare iterators
ERROR:
Line 6: Char 17: error: invalid operands to binary expression
('__gnu_cxx::__normal_iterator<char *, std::vector<char, std::allocator<char> > >' and
'std::reverse_iterator<__gnu_cxx::__normal_iterator<char *, std::vector<char, std::allocator<char> > > >')
while(i != j) {