Reverse vector<string> elements

void reverseString(vector& s) {
auto i=s.begin();
auto j=s.end();
while(i<j)
{
swap(s[i],s[j]); //how to access elements at the iterator…
i++;j–;
)
}

hello @yogeshcsc20

if u want to reverse the vector of string then so this
int i=0 // first index of vector
int j=n-1 // lasr inde of vector

while(i<j){
swap(s[i],s[j]);
i++;
j–;
}

to access value of iterator use * (same as we use to do with pointer)

Tried //swap(*i,*j);

Still unable to do swap of elements. But in your printing example the iterartor worked fine.

try this . . . . . . . . . . .

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.