Reverse A String

Note:

This code was written during a crunch period and isn't perfect. There will be some errant spacing, some files will be using namespace std, etc. But it's all still usable and can be a handy guideline if you're learning Data Structures.

#include <vector>
#include <iostream>
#include <string>

std::string stringRev(std::string input, int indy)
{
    if (indy == input.length() / 2)
    {
        return input;
    }

    char tmp = input[indy];
    input[indy] = input[input.length() - indy - 1];
    input[input.length() - indy - 1] = tmp;

    return stringRev(input, indy + 1);
}

int main(int argc, char *argv[])
{
    std::string test = "olleh";
    std::cout << test << std::endl;
    std::string tset = stringRev(test, 0);
    std::cout << tset << '\n'<< std::endl;

    test = "selppa";
    std::cout << test << std::endl;
    tset = stringRev(test, 0);
    std::cout << tset << '\n' << std::endl;

    test = "neve";
    std::cout << test << std::endl;
    tset = stringRev(test, 0);
    std::cout << tset << '\n'<< std::endl;

    test = "ddo";
    std::cout << test << std::endl;
    tset = stringRev(test, 0);
    std::cout << tset << '\n' << std::endl;
}