Check out example codes for "swap first and last character of string in c++". It will help you in understanding the concepts better.

Code Example 1

std::swap(str.front(), str.back());

Learn ReactJs, React Native from akashmittal.com