#include #include #include using namespace std ; void reverse(char array1[] , int leftIndex, int rightIndex ) { char tempChar ; if ( rightIndex <= leftIndex ) return ; tempChar = array1[ leftIndex ] ; array1[ leftIndex ] = array1[ rightIndex ] ; array1[ rightIndex ] = tempChar ; leftIndex++ ; rightIndex-- ; reverse( array1, leftIndex, rightIndex ) ; } int main() { //char ptr[] = "some" ; char ptr[] = "table" ; //char ptr[] = "A string to be reversed." ; reverse( ptr, 0, strlen(ptr) -1 ) ; cout << ptr << endl ; }