Write code to reverse a C-Style String. (C-String means that “abcd” is represented as five characters, including the null character.)
// This question is for C/C++ programmer.
// #include <algorithm> if programming in C++. otherwise, need to write an extra swap function.
void reverseString(string input) {
// first check the input length.
if(input.size() <= 1) return;
int left = 0, right = input.size() - 1;
while(left < right) {
swap(input[left], input[right]);
left++;
right--;
}